rmagick 2.13.2 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

Files changed (380) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +63 -0
  3. data/.editorconfig +17 -0
  4. data/.github/ISSUE_TEMPLATE.md +17 -0
  5. data/.github/workflows/ci.yml +107 -0
  6. data/.gitignore +25 -0
  7. data/.rspec +2 -0
  8. data/.rubocop.yml +37 -0
  9. data/.rubocop_todo.yml +449 -0
  10. data/.yardopts +5 -0
  11. data/CHANGELOG.md +1277 -0
  12. data/CODE_OF_CONDUCT.md +128 -0
  13. data/CONTRIBUTING.md +81 -0
  14. data/Gemfile +4 -0
  15. data/LICENSE +20 -0
  16. data/README.md +324 -0
  17. data/Rakefile +190 -0
  18. data/before_install_linux.sh +69 -0
  19. data/before_install_osx.sh +57 -0
  20. data/deprecated/RMagick.rb +6 -0
  21. data/ext/RMagick/extconf.rb +334 -333
  22. data/ext/RMagick/rmagick.c +129 -127
  23. data/ext/RMagick/rmagick.h +221 -320
  24. data/ext/RMagick/rmdraw.c +458 -767
  25. data/ext/RMagick/rmenum.c +305 -752
  26. data/ext/RMagick/rmfill.c +231 -199
  27. data/ext/RMagick/rmilist.c +437 -478
  28. data/ext/RMagick/rmimage.c +6130 -5342
  29. data/ext/RMagick/rminfo.c +695 -833
  30. data/ext/RMagick/rmkinfo.c +198 -0
  31. data/ext/RMagick/rmmain.c +752 -506
  32. data/ext/RMagick/rmmontage.c +94 -152
  33. data/ext/RMagick/rmpixel.c +619 -425
  34. data/ext/RMagick/rmstruct.c +206 -309
  35. data/ext/RMagick/rmutil.c +514 -344
  36. data/lib/rmagick/version.rb +5 -0
  37. data/lib/rmagick.rb +1 -0
  38. data/lib/rmagick_internal.rb +1922 -0
  39. data/lib/rvg/clippath.rb +35 -39
  40. data/lib/rvg/container.rb +123 -124
  41. data/lib/rvg/deep_equal.rb +45 -49
  42. data/lib/rvg/describable.rb +41 -47
  43. data/lib/rvg/embellishable.rb +380 -411
  44. data/lib/rvg/misc.rb +691 -711
  45. data/lib/rvg/paint.rb +43 -47
  46. data/lib/rvg/pathdata.rb +119 -125
  47. data/lib/rvg/rvg.rb +214 -213
  48. data/lib/rvg/stretchable.rb +153 -162
  49. data/lib/rvg/stylable.rb +111 -117
  50. data/lib/rvg/text.rb +169 -180
  51. data/lib/rvg/transformable.rb +121 -127
  52. data/lib/rvg/units.rb +58 -61
  53. data/rmagick.gemspec +36 -16
  54. metadata +188 -365
  55. data/ChangeLog +0 -773
  56. data/Doxyfile +0 -1514
  57. data/README-Mac-OSX.txt +0 -1
  58. data/README.html +0 -10
  59. data/build_tarball.rake +0 -215
  60. data/doc/comtasks.html +0 -287
  61. data/doc/constants.html +0 -1581
  62. data/doc/css/doc.css +0 -299
  63. data/doc/css/popup.css +0 -34
  64. data/doc/css/ref.css +0 -67
  65. data/doc/draw.html +0 -3269
  66. data/doc/ex/InitialCoords.rb +0 -23
  67. data/doc/ex/NewCoordSys.rb +0 -32
  68. data/doc/ex/OrigCoordSys.rb +0 -18
  69. data/doc/ex/PreserveAspectRatio.rb +0 -205
  70. data/doc/ex/RotateScale.rb +0 -37
  71. data/doc/ex/Skew.rb +0 -38
  72. data/doc/ex/Use01.rb +0 -16
  73. data/doc/ex/Use02.rb +0 -21
  74. data/doc/ex/Use03.rb +0 -16
  75. data/doc/ex/ViewBox.rb +0 -33
  76. data/doc/ex/adaptive_threshold.rb +0 -10
  77. data/doc/ex/add_noise.rb +0 -17
  78. data/doc/ex/affine.rb +0 -48
  79. data/doc/ex/affine_transform.rb +0 -20
  80. data/doc/ex/arc.rb +0 -49
  81. data/doc/ex/arcpath.rb +0 -33
  82. data/doc/ex/arcs01.rb +0 -28
  83. data/doc/ex/arcs02.rb +0 -61
  84. data/doc/ex/average.rb +0 -15
  85. data/doc/ex/axes.rb +0 -64
  86. data/doc/ex/baseline_shift01.rb +0 -18
  87. data/doc/ex/bilevel_channel.rb +0 -9
  88. data/doc/ex/blur_image.rb +0 -12
  89. data/doc/ex/border.rb +0 -10
  90. data/doc/ex/bounding_box.rb +0 -44
  91. data/doc/ex/cbezier1.rb +0 -42
  92. data/doc/ex/cbezier2.rb +0 -42
  93. data/doc/ex/cbezier3.rb +0 -42
  94. data/doc/ex/cbezier4.rb +0 -43
  95. data/doc/ex/cbezier5.rb +0 -43
  96. data/doc/ex/cbezier6.rb +0 -53
  97. data/doc/ex/channel.rb +0 -26
  98. data/doc/ex/charcoal.rb +0 -12
  99. data/doc/ex/chop.rb +0 -29
  100. data/doc/ex/circle.rb +0 -33
  101. data/doc/ex/circle01.rb +0 -17
  102. data/doc/ex/clip_path.rb +0 -60
  103. data/doc/ex/coalesce.rb +0 -60
  104. data/doc/ex/color_fill_to_border.rb +0 -29
  105. data/doc/ex/color_floodfill.rb +0 -28
  106. data/doc/ex/color_histogram.rb +0 -48
  107. data/doc/ex/color_reset.rb +0 -11
  108. data/doc/ex/colorize.rb +0 -16
  109. data/doc/ex/colors.rb +0 -64
  110. data/doc/ex/compose_mask.rb +0 -23
  111. data/doc/ex/composite.rb +0 -135
  112. data/doc/ex/composite_layers.rb +0 -53
  113. data/doc/ex/composite_tiled.rb +0 -23
  114. data/doc/ex/contrast.rb +0 -36
  115. data/doc/ex/crop.rb +0 -31
  116. data/doc/ex/crop_with_gravity.rb +0 -46
  117. data/doc/ex/cubic01.rb +0 -45
  118. data/doc/ex/cubic02.rb +0 -94
  119. data/doc/ex/cycle_colormap.rb +0 -21
  120. data/doc/ex/dissolve.rb +0 -13
  121. data/doc/ex/drawcomp.rb +0 -42
  122. data/doc/ex/drop_shadow.rb +0 -60
  123. data/doc/ex/edge.rb +0 -11
  124. data/doc/ex/ellipse.rb +0 -45
  125. data/doc/ex/ellipse01.rb +0 -22
  126. data/doc/ex/emboss.rb +0 -11
  127. data/doc/ex/enhance.rb +0 -28
  128. data/doc/ex/equalize.rb +0 -11
  129. data/doc/ex/evenodd.rb +0 -43
  130. data/doc/ex/fill_pattern.rb +0 -26
  131. data/doc/ex/flatten_images.rb +0 -36
  132. data/doc/ex/flip.rb +0 -11
  133. data/doc/ex/flop.rb +0 -11
  134. data/doc/ex/font_styles.rb +0 -34
  135. data/doc/ex/fonts.rb +0 -20
  136. data/doc/ex/frame.rb +0 -12
  137. data/doc/ex/gaussian_blur.rb +0 -11
  138. data/doc/ex/get_multiline_type_metrics.rb +0 -42
  139. data/doc/ex/get_pixels.rb +0 -48
  140. data/doc/ex/get_type_metrics.rb +0 -146
  141. data/doc/ex/gradientfill.rb +0 -27
  142. data/doc/ex/grav.rb +0 -46
  143. data/doc/ex/gravity.rb +0 -79
  144. data/doc/ex/group.rb +0 -26
  145. data/doc/ex/hatchfill.rb +0 -27
  146. data/doc/ex/image.rb +0 -46
  147. data/doc/ex/images/Apple.miff +0 -0
  148. data/doc/ex/images/Ballerina.jpg +0 -0
  149. data/doc/ex/images/Ballerina3.jpg +0 -0
  150. data/doc/ex/images/Button_0.gif +0 -0
  151. data/doc/ex/images/Button_1.gif +0 -0
  152. data/doc/ex/images/Button_2.gif +0 -0
  153. data/doc/ex/images/Button_3.gif +0 -0
  154. data/doc/ex/images/Button_4.gif +0 -0
  155. data/doc/ex/images/Button_5.gif +0 -0
  156. data/doc/ex/images/Button_6.gif +0 -0
  157. data/doc/ex/images/Button_7.gif +0 -0
  158. data/doc/ex/images/Button_8.gif +0 -0
  159. data/doc/ex/images/Button_9.gif +0 -0
  160. data/doc/ex/images/Button_A.gif +0 -0
  161. data/doc/ex/images/Button_B.gif +0 -0
  162. data/doc/ex/images/Button_C.gif +0 -0
  163. data/doc/ex/images/Button_D.gif +0 -0
  164. data/doc/ex/images/Button_E.gif +0 -0
  165. data/doc/ex/images/Button_F.gif +0 -0
  166. data/doc/ex/images/Button_G.gif +0 -0
  167. data/doc/ex/images/Button_H.gif +0 -0
  168. data/doc/ex/images/Button_I.gif +0 -0
  169. data/doc/ex/images/Button_J.gif +0 -0
  170. data/doc/ex/images/Button_K.gif +0 -0
  171. data/doc/ex/images/Button_L.gif +0 -0
  172. data/doc/ex/images/Button_M.gif +0 -0
  173. data/doc/ex/images/Button_N.gif +0 -0
  174. data/doc/ex/images/Button_O.gif +0 -0
  175. data/doc/ex/images/Button_P.gif +0 -0
  176. data/doc/ex/images/Button_Q.gif +0 -0
  177. data/doc/ex/images/Button_R.gif +0 -0
  178. data/doc/ex/images/Button_S.gif +0 -0
  179. data/doc/ex/images/Button_T.gif +0 -0
  180. data/doc/ex/images/Button_U.gif +0 -0
  181. data/doc/ex/images/Button_V.gif +0 -0
  182. data/doc/ex/images/Button_W.gif +0 -0
  183. data/doc/ex/images/Button_X.gif +0 -0
  184. data/doc/ex/images/Button_Y.gif +0 -0
  185. data/doc/ex/images/Button_Z.gif +0 -0
  186. data/doc/ex/images/Cheetah.jpg +0 -0
  187. data/doc/ex/images/Coffee.wmf +0 -0
  188. data/doc/ex/images/Flower_Hat.jpg +0 -0
  189. data/doc/ex/images/Gold_Statue.jpg +0 -0
  190. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  191. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  192. data/doc/ex/images/Leaf.miff +0 -0
  193. data/doc/ex/images/No.wmf +0 -0
  194. data/doc/ex/images/Polynesia.jpg +0 -0
  195. data/doc/ex/images/Red_Rocks.jpg +0 -0
  196. data/doc/ex/images/Rocks_On_Beach.miff +0 -0
  197. data/doc/ex/images/Shorts.jpg +0 -0
  198. data/doc/ex/images/Snake.wmf +0 -0
  199. data/doc/ex/images/Violin.jpg +0 -0
  200. data/doc/ex/images/Yellow_Rose.miff +0 -0
  201. data/doc/ex/images/big-duck.gif +0 -0
  202. data/doc/ex/images/duck.gif +0 -0
  203. data/doc/ex/images/duck0.gif +0 -0
  204. data/doc/ex/images/duck1.gif +0 -0
  205. data/doc/ex/images/duck10.gif +0 -0
  206. data/doc/ex/images/duck11.gif +0 -0
  207. data/doc/ex/images/duck12.gif +0 -0
  208. data/doc/ex/images/duck13.gif +0 -0
  209. data/doc/ex/images/duck14.gif +0 -0
  210. data/doc/ex/images/duck15.gif +0 -0
  211. data/doc/ex/images/duck2.gif +0 -0
  212. data/doc/ex/images/duck3.gif +0 -0
  213. data/doc/ex/images/duck4.gif +0 -0
  214. data/doc/ex/images/duck5.gif +0 -0
  215. data/doc/ex/images/duck6.gif +0 -0
  216. data/doc/ex/images/duck7.gif +0 -0
  217. data/doc/ex/images/duck8.gif +0 -0
  218. data/doc/ex/images/duck9.gif +0 -0
  219. data/doc/ex/images/graydient230x6.gif +0 -0
  220. data/doc/ex/images/logo400x83.gif +0 -0
  221. data/doc/ex/images/model.miff +0 -0
  222. data/doc/ex/images/notimplemented.gif +0 -0
  223. data/doc/ex/images/smile.miff +0 -0
  224. data/doc/ex/images/spin.gif +0 -0
  225. data/doc/ex/implode.rb +0 -34
  226. data/doc/ex/level.rb +0 -11
  227. data/doc/ex/level_colors.rb +0 -11
  228. data/doc/ex/line.rb +0 -42
  229. data/doc/ex/line01.rb +0 -23
  230. data/doc/ex/mask.rb +0 -36
  231. data/doc/ex/matte_fill_to_border.rb +0 -40
  232. data/doc/ex/matte_floodfill.rb +0 -33
  233. data/doc/ex/matte_replace.rb +0 -40
  234. data/doc/ex/median_filter.rb +0 -28
  235. data/doc/ex/modulate.rb +0 -11
  236. data/doc/ex/mono.rb +0 -23
  237. data/doc/ex/morph.rb +0 -26
  238. data/doc/ex/mosaic.rb +0 -35
  239. data/doc/ex/motion_blur.rb +0 -11
  240. data/doc/ex/negate.rb +0 -11
  241. data/doc/ex/negate_channel.rb +0 -9
  242. data/doc/ex/nested_rvg.rb +0 -21
  243. data/doc/ex/nonzero.rb +0 -43
  244. data/doc/ex/normalize.rb +0 -11
  245. data/doc/ex/oil_paint.rb +0 -11
  246. data/doc/ex/opacity.rb +0 -37
  247. data/doc/ex/ordered_dither.rb +0 -11
  248. data/doc/ex/path.rb +0 -64
  249. data/doc/ex/pattern1.rb +0 -25
  250. data/doc/ex/pattern2.rb +0 -26
  251. data/doc/ex/polaroid.rb +0 -28
  252. data/doc/ex/polygon.rb +0 -24
  253. data/doc/ex/polygon01.rb +0 -23
  254. data/doc/ex/polyline.rb +0 -23
  255. data/doc/ex/polyline01.rb +0 -23
  256. data/doc/ex/posterize.rb +0 -8
  257. data/doc/ex/preview.rb +0 -9
  258. data/doc/ex/qbezierpath.rb +0 -52
  259. data/doc/ex/quad01.rb +0 -36
  260. data/doc/ex/quantize-m.rb +0 -25
  261. data/doc/ex/radial_blur.rb +0 -9
  262. data/doc/ex/raise.rb +0 -8
  263. data/doc/ex/random_threshold_channel.rb +0 -13
  264. data/doc/ex/rect01.rb +0 -15
  265. data/doc/ex/rect02.rb +0 -22
  266. data/doc/ex/rectangle.rb +0 -35
  267. data/doc/ex/reduce_noise.rb +0 -28
  268. data/doc/ex/remap.rb +0 -12
  269. data/doc/ex/remap_images.rb +0 -21
  270. data/doc/ex/resize_to_fill.rb +0 -10
  271. data/doc/ex/resize_to_fit.rb +0 -10
  272. data/doc/ex/roll.rb +0 -9
  273. data/doc/ex/rotate.rb +0 -45
  274. data/doc/ex/rotate_f.rb +0 -14
  275. data/doc/ex/roundrect.rb +0 -34
  276. data/doc/ex/rubyname.rb +0 -30
  277. data/doc/ex/rvg_clippath.rb +0 -14
  278. data/doc/ex/rvg_linecap.rb +0 -43
  279. data/doc/ex/rvg_linejoin.rb +0 -41
  280. data/doc/ex/rvg_opacity.rb +0 -19
  281. data/doc/ex/rvg_pattern.rb +0 -26
  282. data/doc/ex/rvg_stroke_dasharray.rb +0 -12
  283. data/doc/ex/segment.rb +0 -11
  284. data/doc/ex/sepiatone.rb +0 -8
  285. data/doc/ex/shade.rb +0 -11
  286. data/doc/ex/shadow.rb +0 -31
  287. data/doc/ex/shave.rb +0 -15
  288. data/doc/ex/shear.rb +0 -10
  289. data/doc/ex/sketch.rb +0 -18
  290. data/doc/ex/skewx.rb +0 -52
  291. data/doc/ex/skewy.rb +0 -47
  292. data/doc/ex/smile.rb +0 -125
  293. data/doc/ex/solarize.rb +0 -11
  294. data/doc/ex/sparse_color.rb +0 -55
  295. data/doc/ex/splice.rb +0 -9
  296. data/doc/ex/spread.rb +0 -11
  297. data/doc/ex/stegano.rb +0 -55
  298. data/doc/ex/stroke_dasharray.rb +0 -43
  299. data/doc/ex/stroke_fill.rb +0 -11
  300. data/doc/ex/stroke_linecap.rb +0 -44
  301. data/doc/ex/stroke_linejoin.rb +0 -48
  302. data/doc/ex/stroke_width.rb +0 -49
  303. data/doc/ex/swirl.rb +0 -17
  304. data/doc/ex/text.rb +0 -37
  305. data/doc/ex/text01.rb +0 -17
  306. data/doc/ex/text_align.rb +0 -36
  307. data/doc/ex/text_antialias.rb +0 -38
  308. data/doc/ex/text_styles.rb +0 -21
  309. data/doc/ex/text_undercolor.rb +0 -28
  310. data/doc/ex/texture_fill_to_border.rb +0 -34
  311. data/doc/ex/texture_floodfill.rb +0 -32
  312. data/doc/ex/texturefill.rb +0 -25
  313. data/doc/ex/threshold.rb +0 -13
  314. data/doc/ex/to_blob.rb +0 -14
  315. data/doc/ex/translate.rb +0 -39
  316. data/doc/ex/transparent.rb +0 -38
  317. data/doc/ex/transpose.rb +0 -9
  318. data/doc/ex/transverse.rb +0 -9
  319. data/doc/ex/tref01.rb +0 -25
  320. data/doc/ex/triangle01.rb +0 -16
  321. data/doc/ex/trim.rb +0 -24
  322. data/doc/ex/tspan01.rb +0 -18
  323. data/doc/ex/tspan02.rb +0 -19
  324. data/doc/ex/tspan03.rb +0 -21
  325. data/doc/ex/unsharp_mask.rb +0 -28
  326. data/doc/ex/viewex.rb +0 -35
  327. data/doc/ex/vignette.rb +0 -12
  328. data/doc/ex/watermark.rb +0 -28
  329. data/doc/ex/wave.rb +0 -9
  330. data/doc/ex/wet_floor.rb +0 -59
  331. data/doc/ex/writing_mode01.rb +0 -27
  332. data/doc/ex/writing_mode02.rb +0 -26
  333. data/doc/ilist.html +0 -2056
  334. data/doc/image1.html +0 -4680
  335. data/doc/image2.html +0 -3665
  336. data/doc/image3.html +0 -4522
  337. data/doc/imageattrs.html +0 -1638
  338. data/doc/imusage.html +0 -514
  339. data/doc/index.html +0 -416
  340. data/doc/info.html +0 -1499
  341. data/doc/magick.html +0 -565
  342. data/doc/optequiv.html +0 -2435
  343. data/doc/rvg.html +0 -975
  344. data/doc/rvgclip.html +0 -248
  345. data/doc/rvggroup.html +0 -305
  346. data/doc/rvgimage.html +0 -289
  347. data/doc/rvgpattern.html +0 -475
  348. data/doc/rvgshape.html +0 -406
  349. data/doc/rvgstyle.html +0 -270
  350. data/doc/rvgtext.html +0 -465
  351. data/doc/rvgtspan.html +0 -238
  352. data/doc/rvgtut.html +0 -530
  353. data/doc/rvguse.html +0 -145
  354. data/doc/rvgxform.html +0 -294
  355. data/doc/scripts/doc.js +0 -22
  356. data/doc/scripts/stripeTables.js +0 -23
  357. data/doc/struct.html +0 -1339
  358. data/doc/usage.html +0 -1621
  359. data/examples/constitute.rb +0 -7
  360. data/examples/crop_with_gravity.rb +0 -46
  361. data/examples/demo.rb +0 -324
  362. data/examples/describe.rb +0 -44
  363. data/examples/find_similar_region.rb +0 -34
  364. data/examples/histogram.rb +0 -325
  365. data/examples/identify.rb +0 -187
  366. data/examples/image_opacity.rb +0 -29
  367. data/examples/import_export.rb +0 -31
  368. data/examples/pattern_fill.rb +0 -38
  369. data/examples/rotating_text.rb +0 -45
  370. data/examples/spinner.rb +0 -50
  371. data/examples/thumbnail.rb +0 -65
  372. data/examples/vignette.rb +0 -79
  373. data/ext/RMagick/MANIFEST +0 -358
  374. data/lib/RMagick.rb +0 -1962
  375. data/metaconfig +0 -7
  376. data/post-clean.rb +0 -12
  377. data/post-install.rb +0 -50
  378. data/post-setup.rb +0 -254
  379. data/setup.rb +0 -1585
  380. data/uninstall.rb +0 -76
data/ext/RMagick/rmenum.c CHANGED
@@ -65,47 +65,65 @@ rm_enum_new(VALUE class, VALUE sym, VALUE val)
65
65
  return rb_obj_freeze(rb_class_new_instance(2, argv, class));
66
66
  }
67
67
 
68
+ /**
69
+ * Retrieve C string value of Enum.
70
+ *
71
+ * No Ruby usage (internal function)
72
+ *
73
+ * @param enum_type the Enum object
74
+ * @return the C string value of Enum object
75
+ */
76
+ static const char *
77
+ rm_enum_to_cstr(VALUE enum_type)
78
+ {
79
+ MagickEnum *magick_enum;
80
+
81
+ Data_Get_Struct(enum_type, MagickEnum, magick_enum);
82
+ return rb_id2name(magick_enum->id);
83
+ }
68
84
 
69
85
  /**
70
- * Enum class alloc function.
86
+ * Free Enum or Enum subclass object
71
87
  *
72
88
  * No Ruby usage (internal function)
73
89
  *
74
- * @param class the Ruby class to use
75
- * @return a new enumerator
90
+ * @param magick_enum the enum
91
+ */
92
+ static void rm_enum_free(void *magick_enum)
93
+ {
94
+ xfree(magick_enum);
95
+ }
96
+ /**
97
+ * Enum class alloc function.
98
+ *
99
+ * @return [Magick::Enum] a new enumerator
76
100
  */
77
101
  VALUE
78
102
  Enum_alloc(VALUE class)
79
103
  {
80
- MagickEnum *magick_enum;
81
- volatile VALUE enumr;
104
+ MagickEnum *magick_enum;
105
+ VALUE enumr;
82
106
 
83
- enumr = Data_Make_Struct(class, MagickEnum, NULL, NULL, magick_enum);
84
- rb_obj_freeze(enumr);
85
- return enumr;
107
+ enumr = Data_Make_Struct(class, MagickEnum, NULL, rm_enum_free, magick_enum);
108
+ rb_obj_freeze(enumr);
109
+
110
+ return enumr;
86
111
  }
87
112
 
88
113
 
89
114
  /**
90
115
  * "Case equal" operator for Enum.
91
116
  *
92
- * Ruby usage:
93
- * - @verbatim Enum#=== @endverbatim
94
- *
95
- * Notes:
96
- * - Yes, I know "case equal" is a misnomer.
97
- *
98
- * @param self this object
99
- * @param other the other object
100
- * @return true or false
117
+ * @param other [Object] the other object
118
+ * @return [Boolean] true or false
101
119
  */
102
120
  VALUE
103
121
  Enum_case_eq(VALUE self, VALUE other)
104
122
  {
105
- MagickEnum *this, *that;
106
-
107
123
  if (CLASS_OF(self) == CLASS_OF(other))
108
124
  {
125
+ MagickEnum *this, *that;
126
+
109
127
  Data_Get_Struct(self, MagickEnum, this);
110
128
  Data_Get_Struct(other, MagickEnum, that);
111
129
  return this->val == that->val ? Qtrue : Qfalse;
@@ -118,64 +136,53 @@ Enum_case_eq(VALUE self, VALUE other)
118
136
  /**
119
137
  * Initialize a new Enum instance.
120
138
  *
121
- * Ruby usage:
122
- * - @verbatim Enum#initialize(sym,val) @endverbatim
123
- *
124
- * @param self this object
125
- * @param sym the symbol
126
- * @param val the value for the symbol
127
- * @return self
139
+ * @param sym [Symbol] the symbol as enum name
140
+ * @param val [Numeric] the value for enum
141
+ * @return [Magick::Enum] self
128
142
  */
129
143
  VALUE
130
144
  Enum_initialize(VALUE self, VALUE sym, VALUE val)
131
145
  {
132
- MagickEnum *magick_enum;
146
+ MagickEnum *magick_enum;
133
147
 
134
- Data_Get_Struct(self, MagickEnum, magick_enum);
135
- magick_enum->id = rb_to_id(sym); /* convert symbol to ID */
136
- magick_enum->val = NUM2INT(val);
148
+ Data_Get_Struct(self, MagickEnum, magick_enum);
149
+ magick_enum->id = rb_to_id(sym); /* convert symbol to ID */
150
+ magick_enum->val = NUM2INT(val);
137
151
 
138
- return self;
152
+ return self;
139
153
  }
140
154
 
141
155
 
142
156
  /**
143
157
  * Return the value of an enum.
144
158
  *
145
- * Ruby usage:
146
- * - @verbatim Enum#to_i @endverbatim
147
- *
148
- * @param self this object
149
- * @return this object's value
159
+ * @return [Numeric] this object's value
150
160
  */
151
161
  VALUE
152
162
  Enum_to_i(VALUE self)
153
163
  {
154
- MagickEnum *magick_enum;
164
+ MagickEnum *magick_enum;
155
165
 
156
- Data_Get_Struct(self, MagickEnum, magick_enum);
157
- return INT2NUM(magick_enum->val);
166
+ Data_Get_Struct(self, MagickEnum, magick_enum);
167
+ return INT2NUM(magick_enum->val);
158
168
  }
159
169
 
160
170
 
161
171
  /**
162
172
  * Support Comparable module in Enum.
163
173
  *
164
- * Ruby usage:
165
- * - @verbatim Enum#<=> @endverbatim
166
- *
167
- * Notes:
168
- * - Enums must be instances of the same class to be equal.
169
- *
170
- * @param self this object
171
- * @param other the other object
172
- * @return -1, 0, 1, or nil
174
+ * @param other [Object] the other object
175
+ * @return [-1, 0, 1, nil] the result of compare
173
176
  */
174
177
  VALUE
175
178
  Enum_spaceship(VALUE self, VALUE other)
176
179
  {
177
180
  MagickEnum *this, *that;
178
181
 
182
+ if(CLASS_OF(self) != CLASS_OF(other)) {
183
+ return Qnil;
184
+ }
185
+
179
186
  Data_Get_Struct(self, MagickEnum, this);
180
187
  Data_Get_Struct(other, MagickEnum, that);
181
188
 
@@ -188,51 +195,67 @@ Enum_spaceship(VALUE self, VALUE other)
188
195
  return INT2FIX(-1);
189
196
  }
190
197
 
191
- // Values are equal, check class.
192
-
193
- return rb_funcall(CLASS_OF(self), rm_ID_spaceship, 1, CLASS_OF(other));
198
+ return INT2FIX(0);
194
199
  }
195
200
 
201
+ /**
202
+ * Bitwise OR for enums
203
+ *
204
+ * @param another [Magick::Enum] the another enum
205
+ * @return [Magick::Enum] new Enum instance
206
+ */
207
+ VALUE
208
+ Enum_bitwise_or(VALUE self, VALUE another)
209
+ {
210
+ VALUE new_enum, cls;
211
+ MagickEnum *this, *that, *new_enum_data;
212
+
213
+ cls = CLASS_OF(self);
214
+ if (CLASS_OF(another) != cls)
215
+ {
216
+ rb_raise(rb_eArgError, "Expected class %s but got %s", rb_class2name(cls), rb_class2name(CLASS_OF(another)));
217
+ }
218
+
219
+ new_enum = Enum_alloc(cls);
220
+
221
+ Data_Get_Struct(self, MagickEnum, this);
222
+ Data_Get_Struct(another, MagickEnum, that);
223
+ Data_Get_Struct(new_enum, MagickEnum, new_enum_data);
224
+
225
+ new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rb_id2name(this->id), rb_id2name(that->id)));
226
+ new_enum_data->val = this->val | that->val;
227
+
228
+ return new_enum;
229
+ }
196
230
 
197
231
  /**
198
232
  * Return the name of an enum.
199
233
  *
200
- * Ruby usage:
201
- * - @verbatim Enum#to_s @endverbatim
202
- *
203
- * @param self this object
204
- * @return the name
234
+ * @return [String] the name of an enum
205
235
  */
206
236
  VALUE
207
237
  Enum_to_s(VALUE self)
208
238
  {
209
- MagickEnum *magick_enum;
210
-
211
- Data_Get_Struct(self, MagickEnum, magick_enum);
212
- return rb_str_new2(rb_id2name(magick_enum->id));
239
+ return rb_str_new2(rm_enum_to_cstr(self));
213
240
  }
214
241
 
215
242
 
216
243
  /**
217
244
  * Initialize method for all Enum subclasses.
218
245
  *
219
- * Ruby usage:
220
- * - @verbatim xxx#initialize(sym,val) @endverbatim
221
- *
222
- * @param self this object
223
- * @param sym the symbol
224
- * @param val the value of the symbol
225
- * @return self
246
+ * @param sym [Symbol] the symbol as enum name
247
+ * @param val [Numeric] the value for enum
248
+ * @return [Magick::Enum] self
226
249
  */
227
250
  VALUE
228
251
  Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
229
252
  {
230
253
  VALUE super_argv[2];
231
- volatile VALUE enumerators;
254
+ VALUE enumerators;
232
255
 
233
256
  super_argv[0] = sym;
234
257
  super_argv[1] = val;
235
- (void) rb_call_super(2, (const VALUE *)super_argv);
258
+ rb_call_super(2, (const VALUE *)super_argv);
236
259
 
237
260
  if (rb_cvar_defined(CLASS_OF(self), rb_intern(ENUMERATORS_CLASS_VAR)) != Qtrue)
238
261
  {
@@ -240,7 +263,9 @@ Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
240
263
  }
241
264
 
242
265
  enumerators = rb_cv_get(CLASS_OF(self), ENUMERATORS_CLASS_VAR);
243
- (void) rb_ary_push(enumerators, self);
266
+ rb_ary_push(enumerators, self);
267
+
268
+ RB_GC_GUARD(enumerators);
244
269
 
245
270
  return self;
246
271
  }
@@ -249,11 +274,7 @@ Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
249
274
  /**
250
275
  * Enum subclass #inspect.
251
276
  *
252
- * Ruby usage:
253
- * - @verbatim xxx#inspect @endverbatim
254
- *
255
- * @param self this object
256
- * @return string representation of self
277
+ * @return [String] representation of self
257
278
  */
258
279
  static VALUE
259
280
  Enum_type_inspect(VALUE self)
@@ -262,7 +283,7 @@ Enum_type_inspect(VALUE self)
262
283
  MagickEnum *magick_enum;
263
284
 
264
285
  Data_Get_Struct(self, MagickEnum, magick_enum);
265
- sprintf(str, "%.48s=%d", rb_id2name(magick_enum->id), magick_enum->val);
286
+ snprintf(str, sizeof(str), "%.48s=%d", rb_id2name(magick_enum->id), magick_enum->val);
266
287
 
267
288
  return rb_str_new2(str);
268
289
  }
@@ -271,21 +292,20 @@ Enum_type_inspect(VALUE self)
271
292
  /**
272
293
  * Behaves like #each if a block is present, otherwise like #to_a.
273
294
  *
274
- * Ruby usage:
275
- * - @verbatim xxx.values @endverbatim
276
- * - @verbatim xxx.values {|v| } @endverbatim
277
- *
278
- * Notes:
279
- * - Defined for each Enum subclass
295
+ * @overload values
296
+ * @return [Array<Magick::Enum>] the enum values
280
297
  *
281
- * @param class the subclass
282
- * @return iterator over values if given block, a copy of the values otherwise
298
+ * @overload values
299
+ * iterator over values if given block
300
+ * @yield [val]
301
+ * @yieldparam val [Magick::Enum] an enum
302
+ * @return [Magick::Enum] self
283
303
  */
284
304
  static VALUE
285
305
  Enum_type_values(VALUE class)
286
306
  {
287
- volatile VALUE enumerators, copy;
288
- volatile VALUE rv;
307
+ VALUE enumerators, copy;
308
+ VALUE rv;
289
309
  int x;
290
310
 
291
311
  enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
@@ -294,7 +314,7 @@ Enum_type_values(VALUE class)
294
314
  {
295
315
  for (x = 0; x < RARRAY_LEN(enumerators); x++)
296
316
  {
297
- (void) rb_yield(rb_ary_entry(enumerators, x));
317
+ rb_yield(rb_ary_entry(enumerators, x));
298
318
  }
299
319
  rv = class;
300
320
  }
@@ -303,460 +323,222 @@ Enum_type_values(VALUE class)
303
323
  copy = rb_ary_new2(RARRAY_LEN(enumerators));
304
324
  for (x = 0; x < RARRAY_LEN(enumerators); x++)
305
325
  {
306
- (void) rb_ary_push(copy, rb_ary_entry(enumerators, x));
326
+ rb_ary_push(copy, rb_ary_entry(enumerators, x));
307
327
  }
308
328
  rb_obj_freeze(copy);
309
329
  rv = copy;
310
330
  }
311
331
 
332
+ RB_GC_GUARD(enumerators);
333
+ RB_GC_GUARD(copy);
334
+ RB_GC_GUARD(rv);
335
+
312
336
  return rv;
313
337
  }
314
338
 
315
-
316
339
  /**
317
- * Construct a ClassType enum object for the specified value.
340
+ * Find enum object for the specified value.
318
341
  *
319
342
  * No Ruby usage (internal function)
320
343
  *
321
- * @param cls the class type
322
- * @return a new enumerator
344
+ * @param class the class type
345
+ * @param value the value for enum
346
+ * @return a enumerator
323
347
  */
324
- VALUE
325
- ClassType_new(ClassType cls)
326
- {
327
- const char *name;
328
-
329
- switch(cls)
330
- {
331
- default:
332
- case UndefinedClass:
333
- name = "UndefineClass";
334
- break;
335
- case DirectClass:
336
- name = "DirectClass";
337
- break;
338
- case PseudoClass:
339
- name = "PseudoClass";
340
- break;
341
- }
342
348
 
343
- return rm_enum_new(Class_ClassType, ID2SYM(rb_intern(name)), INT2FIX(cls));
344
- }
345
-
346
-
347
- /**
348
- * Construct a ColorspaceType enum object for the specified value.
349
- *
350
- * No Ruby usage (internal function)
351
- *
352
- * @param cs the ColorspaceType
353
- * @return a new ColorspaceType enumerator
354
- */
355
349
  VALUE
356
- ColorspaceType_new(ColorspaceType cs)
350
+ Enum_find(VALUE class, int val)
357
351
  {
358
- const char *name;
352
+ VALUE enumerators;
353
+ MagickEnum *magick_enum;
354
+ int x;
359
355
 
360
- switch(cs)
356
+ enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
357
+ enumerators = rm_check_ary_type(enumerators);
358
+
359
+ for (x = 0; x < RARRAY_LEN(enumerators); x++)
361
360
  {
362
- default:
363
- case UndefinedColorspace:
364
- name = "UndefinedColorspace";
365
- break;
366
- case RGBColorspace:
367
- name = "RGBColorspace";
368
- break;
369
- case GRAYColorspace:
370
- name = "GRAYColorspace";
371
- break;
372
- case TransparentColorspace:
373
- name = "TransparentColorspace";
374
- break;
375
- case OHTAColorspace:
376
- name = "OHTAColorspace";
377
- break;
378
- case XYZColorspace:
379
- name = "XYZColorspace";
380
- break;
381
- case YCbCrColorspace:
382
- name = "YCbCrColorspace";
383
- break;
384
- case YCCColorspace:
385
- name = "YCCColorspace";
386
- break;
387
- case YIQColorspace:
388
- name = "YIQColorspace";
389
- break;
390
- case YPbPrColorspace:
391
- name = "YPbPrColorspace";
392
- break;
393
- case YUVColorspace:
394
- name = "YUVColorspace";
395
- break;
396
- case CMYKColorspace:
397
- name = "CMYKColorspace";
398
- break;
399
- case sRGBColorspace:
400
- name = "sRGBColorspace";
401
- break;
402
- case HSLColorspace:
403
- name = "HSLColorspace";
404
- break;
405
- case HWBColorspace:
406
- name = "HWBColorspace";
407
- break;
408
- case HSBColorspace:
409
- name = "HSBColorspace";
410
- break;
411
- case LABColorspace:
412
- name = "LABColorspace";
413
- break;
414
- case Rec601YCbCrColorspace:
415
- name = "Rec601YCbCrColorspace";
416
- break;
417
- case Rec601LumaColorspace:
418
- name = "Rec601LumaColorspace";
419
- break;
420
- case Rec709LumaColorspace:
421
- name = "Rec709LumaColorspace";
422
- break;
423
- case Rec709YCbCrColorspace:
424
- name = "Rec709YCbCrColorspace";
425
- break;
426
- case LogColorspace:
427
- name = "LogColorspace";
428
- break;
429
- case CMYColorspace:
430
- name = "CMYColorspace";
431
- break;
361
+ VALUE enumerator = rb_ary_entry(enumerators, x);
362
+ Data_Get_Struct(enumerator, MagickEnum, magick_enum);
363
+ if (magick_enum->val == val)
364
+ {
365
+ return enumerator;
366
+ }
432
367
  }
433
368
 
434
- return rm_enum_new(Class_ColorspaceType, ID2SYM(rb_intern(name)), INT2FIX(cs));
435
-
369
+ return Qnil;
436
370
  }
437
371
 
438
372
 
439
373
  /**
440
- * Return the name of a CompositeOperator enum as a string.
374
+ * Returns a ClassType enum object for the specified value.
441
375
  *
442
376
  * No Ruby usage (internal function)
443
377
  *
444
- * @param op the CompositeOperator
445
- * @return the name
378
+ * @param cls the class type
379
+ * @return a new enumerator
446
380
  */
447
- static const char *
448
- CompositeOperator_name(CompositeOperator op)
381
+ VALUE
382
+ ClassType_find(ClassType cls)
449
383
  {
450
- switch (op)
451
- {
452
- ENUM_TO_NAME(UndefinedCompositeOp)
453
- ENUM_TO_NAME(NoCompositeOp)
454
- ENUM_TO_NAME(AddCompositeOp)
455
- ENUM_TO_NAME(AtopCompositeOp)
456
- #if defined(HAVE_ENUM_BLURCOMPOSITEOP)
457
- ENUM_TO_NAME(BlurCompositeOp)
458
- #endif
459
- ENUM_TO_NAME(BumpmapCompositeOp)
460
- ENUM_TO_NAME(ChangeMaskCompositeOp)
461
- ENUM_TO_NAME(ClearCompositeOp)
462
- ENUM_TO_NAME(ColorBurnCompositeOp)
463
- ENUM_TO_NAME(BlendCompositeOp)
464
- ENUM_TO_NAME(ColorDodgeCompositeOp)
465
- ENUM_TO_NAME(ExclusionCompositeOp)
466
- ENUM_TO_NAME(HardLightCompositeOp)
467
- ENUM_TO_NAME(SoftLightCompositeOp)
468
- ENUM_TO_NAME(ColorizeCompositeOp)
469
- ENUM_TO_NAME(CopyBlueCompositeOp)
470
- ENUM_TO_NAME(CopyCompositeOp)
471
- ENUM_TO_NAME(CopyCyanCompositeOp)
472
- ENUM_TO_NAME(CopyMagentaCompositeOp)
473
- ENUM_TO_NAME(CopyYellowCompositeOp)
474
- ENUM_TO_NAME(CopyBlackCompositeOp)
475
- ENUM_TO_NAME(CopyGreenCompositeOp)
476
- ENUM_TO_NAME(CopyOpacityCompositeOp)
477
- ENUM_TO_NAME(CopyRedCompositeOp)
478
- ENUM_TO_NAME(DarkenCompositeOp)
479
- #if defined(HAVE_ENUM_DISTORTCOMPOSITEOP)
480
- ENUM_TO_NAME(DistortCompositeOp)
481
- #endif
482
- ENUM_TO_NAME(DivideCompositeOp)
483
- ENUM_TO_NAME(DstAtopCompositeOp)
484
- ENUM_TO_NAME(DstCompositeOp)
485
- ENUM_TO_NAME(DstInCompositeOp)
486
- ENUM_TO_NAME(DstOutCompositeOp)
487
- ENUM_TO_NAME(DstOverCompositeOp)
488
- ENUM_TO_NAME(DifferenceCompositeOp)
489
- ENUM_TO_NAME(DisplaceCompositeOp)
490
- ENUM_TO_NAME(DissolveCompositeOp)
491
- ENUM_TO_NAME(HueCompositeOp)
492
- ENUM_TO_NAME(InCompositeOp)
493
- ENUM_TO_NAME(LightenCompositeOp)
494
- #if defined(HAVE_ENUM_LINEARBURNCOMPOSITEOP)
495
- ENUM_TO_NAME(LinearBurnCompositeOp)
496
- #endif
497
- #if defined(HAVE_ENUM_LINEARDODGECOMPOSITEOP)
498
- ENUM_TO_NAME(LinearDodgeCompositeOp)
499
- #endif
500
- ENUM_TO_NAME(LinearLightCompositeOp)
501
- ENUM_TO_NAME(LuminizeCompositeOp)
502
- #if defined(HAVE_ENUM_MATHEMATICSCOMPOSITEOP)
503
- ENUM_TO_NAME(MathematicsCompositeOp)
504
- #endif
505
- ENUM_TO_NAME(MinusCompositeOp)
506
- ENUM_TO_NAME(ModulateCompositeOp)
507
- ENUM_TO_NAME(MultiplyCompositeOp)
508
- ENUM_TO_NAME(OutCompositeOp)
509
- ENUM_TO_NAME(OverCompositeOp)
510
- ENUM_TO_NAME(OverlayCompositeOp)
511
- #if defined(HAVE_ENUM_PEGTOPLIGHTCOMPOSITEOP)
512
- ENUM_TO_NAME(PegtopLightCompositeOp)
513
- #endif
514
- #if defined(HAVE_ENUM_PINLIGHTCOMPOSITEOP)
515
- ENUM_TO_NAME(PinLightCompositeOp)
516
- #endif
517
- ENUM_TO_NAME(PlusCompositeOp)
518
- ENUM_TO_NAME(ReplaceCompositeOp)
519
- ENUM_TO_NAME(SaturateCompositeOp)
520
- ENUM_TO_NAME(ScreenCompositeOp)
521
- ENUM_TO_NAME(SrcAtopCompositeOp)
522
- ENUM_TO_NAME(SrcCompositeOp)
523
- ENUM_TO_NAME(SrcInCompositeOp)
524
- ENUM_TO_NAME(SrcOutCompositeOp)
525
- ENUM_TO_NAME(SrcOverCompositeOp)
526
- ENUM_TO_NAME(SubtractCompositeOp)
527
- ENUM_TO_NAME(ThresholdCompositeOp)
528
- #if defined(HAVE_ENUM_VIVIDLIGHTCOMPOSITEOP)
529
- ENUM_TO_NAME(VividLightCompositeOp)
530
- #endif
531
- ENUM_TO_NAME(XorCompositeOp)
532
- }
533
-
534
- return "UndefinedCompositeOp";
384
+ return Enum_find(Class_ClassType, cls);
535
385
  }
536
386
 
537
387
 
538
388
  /**
539
- * Construct a CompositeOperator enum object for the specified value.
389
+ * Returns a ColorspaceType enum object for the specified value.
540
390
  *
541
391
  * No Ruby usage (internal function)
542
392
  *
543
- * @param op the CompositeOperator
544
- * @return a new CompositeOperator enumerator
393
+ * @param cs the ColorspaceType
394
+ * @return a new ColorspaceType enumerator
545
395
  */
546
396
  VALUE
547
- CompositeOperator_new(CompositeOperator op)
397
+ ColorspaceType_find(ColorspaceType cs)
548
398
  {
549
- const char *name = CompositeOperator_name(op);
550
- return rm_enum_new(Class_CompositeOperator, ID2SYM(rb_intern(name)), INT2FIX(op));
399
+ return Enum_find(Class_ColorspaceType, cs);
551
400
  }
552
401
 
553
402
 
554
403
  /**
555
- * Return the name of a CompressionType enum as a string.
404
+ * Return the string representation of a ComplianceType value.
556
405
  *
557
406
  * No Ruby usage (internal function)
558
407
  *
559
- * @param ct the CompressionType
560
- * @return the name
408
+ * Notes:
409
+ * - xMagick will OR multiple compliance types so we have to arbitrarily pick
410
+ * one name.
411
+ * - Set the compliance argument to the selected value.
412
+ *
413
+ * @param c the ComplianceType value
414
+ * @return the string
561
415
  */
562
- static const char *
563
- CompressionType_name(CompressionType ct)
416
+ const char *
417
+ ComplianceType_name(ComplianceType *c)
564
418
  {
565
- switch (ct)
419
+ if ((*c & (SVGCompliance|X11Compliance|XPMCompliance))
420
+ == (SVGCompliance|X11Compliance|XPMCompliance))
566
421
  {
567
- ENUM_TO_NAME(UndefinedCompression)
568
- ENUM_TO_NAME(NoCompression)
569
- #if defined(HAVE_ENUM_B44COMPRESSION)
570
- ENUM_TO_NAME(B44Compression)
571
- #endif
572
- #if defined(HAVE_ENUM_B44ACOMPRESSION)
573
- ENUM_TO_NAME(B44ACompression)
574
- #endif
575
- ENUM_TO_NAME(BZipCompression)
576
- #if defined(HAVE_ENUM_DXT1COMPRESSION)
577
- ENUM_TO_NAME(DXT1Compression)
578
- #endif
579
- #if defined(HAVE_ENUM_DXT3COMPRESSION)
580
- ENUM_TO_NAME(DXT3Compression)
581
- #endif
582
- #if defined(HAVE_ENUM_DXT5COMPRESSION)
583
- ENUM_TO_NAME(DXT5Compression)
584
- #endif
585
- ENUM_TO_NAME(FaxCompression)
586
- ENUM_TO_NAME(Group4Compression)
587
- ENUM_TO_NAME(JPEGCompression)
588
- ENUM_TO_NAME(JPEG2000Compression)
589
- ENUM_TO_NAME(LosslessJPEGCompression)
590
- ENUM_TO_NAME(LZWCompression)
591
- #if defined(HAVE_ENUM_PIZCOMPRESSION)
592
- ENUM_TO_NAME(PizCompression)
593
- #endif
594
- #if defined(HAVE_ENUM_PXR24COMPRESSION)
595
- ENUM_TO_NAME(Pxr24Compression)
596
- #endif
597
- ENUM_TO_NAME(RLECompression)
598
- ENUM_TO_NAME(ZipCompression)
599
- #if defined(HAVE_ENUM_ZIPSCOMPRESSION)
600
- ENUM_TO_NAME(ZipSCompression)
601
- #endif
602
- }
603
-
604
- return "UndefinedCompression";
422
+ return "AllCompliance";
423
+ }
424
+ else if (*c & SVGCompliance)
425
+ {
426
+ *c = SVGCompliance;
427
+ return "SVGCompliance";
428
+ }
429
+ else if (*c & X11Compliance)
430
+ {
431
+ *c = X11Compliance;
432
+ return "X11Compliance";
433
+ }
434
+ else if (*c & XPMCompliance)
435
+ {
436
+ *c = XPMCompliance;
437
+ return "XPMCompliance";
438
+ }
439
+ else if (*c == NoCompliance)
440
+ {
441
+ *c = NoCompliance;
442
+ return "NoCompliance";
443
+ }
444
+ else
445
+ {
446
+ *c = UndefinedCompliance;
447
+ return "UndefinedCompliance";
448
+ }
605
449
  }
606
450
 
607
451
 
608
452
  /**
609
- * Construct a CompressionType enum object for the specified value.
453
+ * Returns a ComplianceType enum object for the specified value.
610
454
  *
611
455
  * No Ruby usage (internal function)
612
456
  *
613
- * @param ct the CompressionType
614
- * @return a new CompressionType enumerator
457
+ * @param compliance the C ComplianceType value
458
+ * @return the Ruby ComplianceType enum object
615
459
  */
616
460
  VALUE
617
- CompressionType_new(CompressionType ct)
461
+ ComplianceType_find(ComplianceType compliance)
618
462
  {
619
- const char *name = CompressionType_name(ct);
620
- return rm_enum_new(Class_CompressionType, ID2SYM(rb_intern(name)), INT2FIX(ct));
621
- }
622
-
463
+ ComplianceType c;
623
464
 
624
- /**
625
- * Return the name of a DisposeType enum as a string.
626
- *
627
- * No Ruby usage (internal function)
628
- *
629
- * @param type the DisposeType
630
- * @return the name
631
- */
632
- static const char *
633
- DisposeType_name(DisposeType type)
634
- {
635
- switch(type)
465
+ // Turn off undefined bits
466
+ if ((compliance & (SVGCompliance|X11Compliance|XPMCompliance))
467
+ == (SVGCompliance|X11Compliance|XPMCompliance))
636
468
  {
637
- ENUM_TO_NAME(UndefinedDispose)
638
- ENUM_TO_NAME(BackgroundDispose)
639
- ENUM_TO_NAME(NoneDispose)
640
- ENUM_TO_NAME(PreviousDispose)
469
+ c = SVGCompliance|X11Compliance|XPMCompliance;
641
470
  }
642
-
643
- return "UndefinedDispose";
471
+ else if (compliance & SVGCompliance)
472
+ {
473
+ c = SVGCompliance;
474
+ }
475
+ else if (compliance & X11Compliance)
476
+ {
477
+ c = X11Compliance;
478
+ }
479
+ else if (compliance & XPMCompliance)
480
+ {
481
+ c = XPMCompliance;
482
+ }
483
+ else if (compliance == NoCompliance)
484
+ {
485
+ c = NoCompliance;
486
+ }
487
+ else
488
+ {
489
+ c = UndefinedCompliance;
490
+ }
491
+ return Enum_find(Class_ComplianceType, c);
644
492
  }
645
493
 
646
494
 
647
495
  /**
648
- * Construct a DisposeType enum object for the specified value..new.
496
+ * Returns a CompositeOperator enum object for the specified value.
649
497
  *
650
498
  * No Ruby usage (internal function)
651
499
  *
652
- * @param type the DisposeType
653
- * @return a new DisposeType enumerator
500
+ * @param op the CompositeOperator
501
+ * @return a new CompositeOperator enumerator
654
502
  */
655
503
  VALUE
656
- DisposeType_new(DisposeType type)
504
+ CompositeOperator_find(CompositeOperator op)
657
505
  {
658
- const char *name = DisposeType_name(type);
659
- return rm_enum_new(Class_DisposeType, ID2SYM(rb_intern(name)), INT2FIX(type));
660
- }
661
-
662
-
663
- /**
664
- * Return the name of a FilterTypes enum as a string.
665
- *
666
- * No Ruby usage (internal function)
667
- *
668
- * @param type the FilterTypes
669
- * @return the name
670
- */
671
- static const char *
672
- FilterTypes_name(FilterTypes type)
673
- {
674
- switch(type)
675
- {
676
- ENUM_TO_NAME(UndefinedFilter)
677
- ENUM_TO_NAME(PointFilter)
678
- ENUM_TO_NAME(BoxFilter)
679
- ENUM_TO_NAME(TriangleFilter)
680
- ENUM_TO_NAME(HermiteFilter)
681
- ENUM_TO_NAME(HanningFilter)
682
- ENUM_TO_NAME(HammingFilter)
683
- ENUM_TO_NAME(BlackmanFilter)
684
- ENUM_TO_NAME(GaussianFilter)
685
- ENUM_TO_NAME(QuadraticFilter)
686
- ENUM_TO_NAME(CubicFilter)
687
- ENUM_TO_NAME(CatromFilter)
688
- ENUM_TO_NAME(MitchellFilter)
689
- ENUM_TO_NAME(LanczosFilter)
690
- ENUM_TO_NAME(BesselFilter)
691
- ENUM_TO_NAME(SincFilter)
692
- #if defined(HAVE_ENUM_KAISERFILTER)
693
- ENUM_TO_NAME(KaiserFilter)
694
- #endif
695
- #if defined(HAVE_ENUM_WELSHFILTER)
696
- ENUM_TO_NAME(WelshFilter)
697
- #endif
698
- #if defined(HAVE_ENUM_PARZENFILTER)
699
- ENUM_TO_NAME(ParzenFilter)
700
- #endif
701
- #if defined(HAVE_ENUM_LAGRANGEFILTER)
702
- ENUM_TO_NAME(LagrangeFilter)
703
- #endif
704
- #if defined(HAVE_ENUM_BOHMANFILTER)
705
- ENUM_TO_NAME(BohmanFilter)
706
- #endif
707
- #if defined(HAVE_ENUM_BARTLETTFILTER)
708
- ENUM_TO_NAME(BartlettFilter)
709
- #endif
710
- #if defined(HAVE_ENUM_SENTINELFILTER)
711
- // not a real filter name - defeat gcc warning message
712
- case SentinelFilter:
713
- break;
714
- #endif
715
- }
716
-
717
- return "UndefinedFilter";
506
+ return Enum_find(Class_CompositeOperator, op);
718
507
  }
719
508
 
720
509
 
721
510
  /**
722
- * Construct an FilterTypes enum object for the specified value.
511
+ * Returns a CompressionType enum object for the specified value.
723
512
  *
724
513
  * No Ruby usage (internal function)
725
514
  *
726
- * @param type the FilterTypes
727
- * @return a new FilterTypes enumerator
515
+ * @param ct the CompressionType
516
+ * @return a new CompressionType enumerator
728
517
  */
729
518
  VALUE
730
- FilterTypes_new(FilterTypes type)
519
+ CompressionType_find(CompressionType ct)
731
520
  {
732
- const char *name = FilterTypes_name(type);
733
- return rm_enum_new(Class_FilterTypes, ID2SYM(rb_intern(name)), INT2FIX(type));
521
+ return Enum_find(Class_CompressionType, ct);
734
522
  }
735
523
 
736
524
 
737
525
  /**
738
- * Return the name of a EndianType enum as a string.
526
+ * Returns a DisposeType enum object for the specified value..new.
739
527
  *
740
528
  * No Ruby usage (internal function)
741
529
  *
742
- * @param type the EndianType
743
- * @return the name
530
+ * @param type the DisposeType
531
+ * @return a new DisposeType enumerator
744
532
  */
745
- static const char *
746
- EndianType_name(EndianType type)
533
+ VALUE
534
+ DisposeType_find(DisposeType type)
747
535
  {
748
- switch(type)
749
- {
750
- ENUM_TO_NAME(UndefinedEndian)
751
- ENUM_TO_NAME(LSBEndian)
752
- ENUM_TO_NAME(MSBEndian)
753
- }
754
- return "UndefinedEndian";
536
+ return Enum_find(Class_DisposeType, type);
755
537
  }
756
538
 
757
539
 
758
540
  /**
759
- * Construct an EndianType enum object.
541
+ * Returns an EndianType enum object.
760
542
  *
761
543
  * No Ruby usage (internal function)
762
544
  *
@@ -764,46 +546,29 @@ EndianType_name(EndianType type)
764
546
  * @return a new EndianType enumerator
765
547
  */
766
548
  VALUE
767
- EndianType_new(EndianType type)
549
+ EndianType_find(EndianType type)
768
550
  {
769
- const char *name = EndianType_name(type);
770
- return rm_enum_new(Class_EndianType, ID2SYM(rb_intern(name)), INT2FIX(type));
551
+ return Enum_find(Class_EndianType, type);
771
552
  }
772
553
 
773
554
 
774
555
  /**
775
- * Return the name of a GravityType enum as a string.
556
+ * Returns a FilterType enum object for the specified value.
776
557
  *
777
558
  * No Ruby usage (internal function)
778
559
  *
779
- * @param type the GravityType
780
- * @return the name
560
+ * @param type the FilterType
561
+ * @return a new FilterType enumerator
781
562
  */
782
- static const char *
783
- GravityType_name(GravityType type)
563
+ VALUE
564
+ FilterType_find(FilterType type)
784
565
  {
785
- switch(type)
786
- {
787
- ENUM_TO_NAME(ForgetGravity)
788
- ENUM_TO_NAME(NorthWestGravity)
789
- ENUM_TO_NAME(NorthGravity)
790
- ENUM_TO_NAME(NorthEastGravity)
791
- ENUM_TO_NAME(WestGravity)
792
- ENUM_TO_NAME(CenterGravity)
793
- ENUM_TO_NAME(EastGravity)
794
- ENUM_TO_NAME(SouthWestGravity)
795
- ENUM_TO_NAME(SouthGravity)
796
- ENUM_TO_NAME(SouthEastGravity)
797
- ENUM_TO_NAME(StaticGravity)
798
- }
799
-
800
- // Defeat "duplicate case value" error.
801
- return "UndefinedGravity";
566
+ return Enum_find(Class_FilterType, type);
802
567
  }
803
568
 
804
569
 
805
570
  /**
806
- * Construct an GravityType enum object for the specified value.
571
+ * Returns a GravityType enum object for the specified value.
807
572
  *
808
573
  * No Ruby usage (internal function)
809
574
  *
@@ -811,46 +576,14 @@ GravityType_name(GravityType type)
811
576
  * @return a new GravityType enumerator
812
577
  */
813
578
  VALUE
814
- GravityType_new(GravityType type)
815
- {
816
- const char *name = GravityType_name(type);
817
- return rm_enum_new(Class_GravityType, ID2SYM(rb_intern(name)), INT2FIX(type));
818
- }
819
-
820
-
821
- /**
822
- * Return the name of a ImageType enum as a string.
823
- *
824
- * No Ruby usage (internal function)
825
- *
826
- * @param type the ImageType
827
- * @return the name
828
- */
829
- static const char *
830
- ImageType_name(ImageType type)
579
+ GravityType_find(GravityType type)
831
580
  {
832
- switch(type)
833
- {
834
- ENUM_TO_NAME(UndefinedType)
835
- ENUM_TO_NAME(BilevelType)
836
- ENUM_TO_NAME(GrayscaleType)
837
- ENUM_TO_NAME(GrayscaleMatteType)
838
- ENUM_TO_NAME(PaletteType)
839
- ENUM_TO_NAME(PaletteMatteType)
840
- ENUM_TO_NAME(TrueColorType)
841
- ENUM_TO_NAME(TrueColorMatteType)
842
- ENUM_TO_NAME(ColorSeparationType)
843
- ENUM_TO_NAME(ColorSeparationMatteType)
844
- ENUM_TO_NAME(OptimizeType)
845
- ENUM_TO_NAME(PaletteBilevelMatteType)
846
- }
847
-
848
- return "UndefinedType";
581
+ return Enum_find(Class_GravityType, type);
849
582
  }
850
583
 
851
584
 
852
585
  /**
853
- * Construct an ImageType enum object for the specified value.
586
+ * Returns an ImageType enum object for the specified value.
854
587
  *
855
588
  * No Ruby usage (internal function)
856
589
  *
@@ -858,42 +591,14 @@ ImageType_name(ImageType type)
858
591
  * @return a new ImageType enumerator
859
592
  */
860
593
  VALUE
861
- ImageType_new(ImageType type)
594
+ ImageType_find(ImageType type)
862
595
  {
863
- const char *name = ImageType_name(type);
864
- return rm_enum_new(Class_ImageType, ID2SYM(rb_intern(name)), INT2FIX(type));
596
+ return Enum_find(Class_ImageType, type);
865
597
  }
866
598
 
867
599
 
868
600
  /**
869
- * Return the name of a InterlaceType enum as a string.
870
- *
871
- * No Ruby usage (internal function)
872
- *
873
- * @param interlace the InterlaceType
874
- * @return the name
875
- */
876
- static const char *
877
- InterlaceType_name(InterlaceType interlace)
878
- {
879
- switch(interlace)
880
- {
881
- ENUM_TO_NAME(UndefinedInterlace)
882
- ENUM_TO_NAME(GIFInterlace)
883
- ENUM_TO_NAME(JPEGInterlace)
884
- ENUM_TO_NAME(PNGInterlace)
885
- ENUM_TO_NAME(NoInterlace)
886
- ENUM_TO_NAME(LineInterlace)
887
- ENUM_TO_NAME(PlaneInterlace)
888
- ENUM_TO_NAME(PartitionInterlace)
889
- }
890
-
891
- return "UndefinedInterlace";
892
- }
893
-
894
-
895
- /**
896
- * Construct an InterlaceType enum object for the specified value.
601
+ * Returns an InterlaceType enum object for the specified value.
897
602
  *
898
603
  * No Ruby usage (internal function)
899
604
  *
@@ -901,315 +606,164 @@ InterlaceType_name(InterlaceType interlace)
901
606
  * @return a new InterlaceType enumerator
902
607
  */
903
608
  VALUE
904
- InterlaceType_new(InterlaceType interlace)
609
+ InterlaceType_find(InterlaceType interlace)
905
610
  {
906
- const char *name = InterlaceType_name(interlace);
907
- return rm_enum_new(Class_InterlaceType, ID2SYM(rb_intern(name)), INT2FIX(interlace));
611
+ return Enum_find(Class_InterlaceType, interlace);
908
612
  }
909
613
 
910
614
 
911
615
  /**
912
- * Return the name of a InterpolatePixelMethod enum as a string.
616
+ * Returns an OrientationType enum object for the specified value.
913
617
  *
914
618
  * No Ruby usage (internal function)
915
619
  *
916
- * @param interpolate the InterpolatePixelMethod
917
- * @return the name
918
- */
919
- static const char *
920
- InterpolatePixelMethod_name(InterpolatePixelMethod interpolate)
921
- {
922
- switch(interpolate)
923
- {
924
- ENUM_TO_NAME(UndefinedInterpolatePixel)
925
- ENUM_TO_NAME(AverageInterpolatePixel)
926
- ENUM_TO_NAME(BicubicInterpolatePixel)
927
- ENUM_TO_NAME(BilinearInterpolatePixel)
928
- ENUM_TO_NAME(FilterInterpolatePixel)
929
- ENUM_TO_NAME(IntegerInterpolatePixel)
930
- ENUM_TO_NAME(MeshInterpolatePixel)
931
- ENUM_TO_NAME(NearestNeighborInterpolatePixel)
932
- ENUM_TO_NAME(SplineInterpolatePixel)
933
- }
934
-
935
- return "UndefinedInterpolatePixel";
936
- }
937
-
938
-
939
- /**
940
- * Construct an InterpolatePixelMethod enum object for the specified value.
941
- *
942
- * No Ruby usage (internal function)
943
- *
944
- * @param interpolate the InterpolatePixelMethod
945
- * @return a new InterpolatePixelMethod enumerator
620
+ * @param type the OrientationType
621
+ * @return a new OrientationType enumerator
946
622
  */
947
623
  VALUE
948
- InterpolatePixelMethod_new(InterpolatePixelMethod interpolate)
624
+ OrientationType_find(OrientationType type)
949
625
  {
950
- const char *name = InterpolatePixelMethod_name(interpolate);
951
- return rm_enum_new(Class_InterpolatePixelMethod, ID2SYM(rb_intern(name)), INT2FIX(interpolate));
626
+ return Enum_find(Class_OrientationType, type);
952
627
  }
953
628
 
954
629
 
955
630
  /**
956
- * Return the name of a MagickLayerMethod enum as a string.
631
+ * Returns a PixelInterpolateMethod enum object for the specified value.
957
632
  *
958
633
  * No Ruby usage (internal function)
959
634
  *
960
- * @param method the MagickLayerMethod
961
- * @return the name
962
- */
963
- static const char *
964
- LAYERMETHODTYPE_NAME(LAYERMETHODTYPE method)
965
- {
966
- switch(method)
967
- {
968
- ENUM_TO_NAME(UndefinedLayer)
969
- ENUM_TO_NAME(CompareAnyLayer)
970
- ENUM_TO_NAME(CompareClearLayer)
971
- ENUM_TO_NAME(CompareOverlayLayer)
972
- ENUM_TO_NAME(OptimizeLayer)
973
- ENUM_TO_NAME(OptimizePlusLayer)
974
- ENUM_TO_NAME(CoalesceLayer)
975
- ENUM_TO_NAME(DisposeLayer)
976
- ENUM_TO_NAME(OptimizeTransLayer)
977
- ENUM_TO_NAME(OptimizeImageLayer)
978
- ENUM_TO_NAME(RemoveDupsLayer)
979
- ENUM_TO_NAME(RemoveZeroLayer)
980
- ENUM_TO_NAME(CompositeLayer)
981
- #if defined(HAVE_ENUM_MERGELAYER)
982
- ENUM_TO_NAME(MergeLayer)
983
- #endif
984
- #if defined(HAVE_ENUM_MOSAICLAYER)
985
- ENUM_TO_NAME(MosaicLayer)
986
- #endif
987
- #if defined(HAVE_ENUM_FLATTENLAYER)
988
- ENUM_TO_NAME(FlattenLayer)
989
- #endif
990
- #if defined(HAVE_ENUM_TRIMBOUNDSLAYER)
991
- ENUM_TO_NAME(TrimBoundsLayer)
992
- #endif
993
- }
994
-
995
- return "UndefinedLayer";
996
- }
997
-
998
-
999
- /**
1000
- * Construct an MagickLayerMethod enum object for the specified value.
1001
- *
1002
- * No Ruby usage (internal function)
1003
- *
1004
- * @param method the MagickLayerMethod
1005
- * @return a new MagickLayerMethod enumerator
635
+ * @param interpolate the PixelInterpolateMethod
636
+ * @return a new PixelInterpolateMethod enumerator
1006
637
  */
1007
638
  VALUE
1008
- LAYERMETHODTYPE_NEW(LAYERMETHODTYPE method)
639
+ PixelInterpolateMethod_find(PixelInterpolateMethod interpolate)
1009
640
  {
1010
- const char *name = LAYERMETHODTYPE_NAME(method);
1011
- return rm_enum_new(CLASS_LAYERMETHODTYPE, ID2SYM(rb_intern(name)), INT2FIX(method));
641
+ return Enum_find(Class_PixelInterpolateMethod, interpolate);
1012
642
  }
1013
643
 
1014
644
 
1015
645
  /**
1016
- * Return the name of a OrientationType enum as a string.
646
+ * Construct an RenderingIntent enum object for the specified value.
1017
647
  *
1018
648
  * No Ruby usage (internal function)
1019
649
  *
1020
- * @param type the OreintationType
1021
- * @return the name
650
+ * @param intent the RenderingIntent
651
+ * @return a new RenderingIntent enumerator
1022
652
  */
1023
- static const char *
1024
- OrientationType_name(OrientationType type)
653
+ VALUE
654
+ RenderingIntent_find(RenderingIntent intent)
1025
655
  {
1026
- switch(type)
1027
- {
1028
- ENUM_TO_NAME(UndefinedOrientation)
1029
- ENUM_TO_NAME(TopLeftOrientation)
1030
- ENUM_TO_NAME(TopRightOrientation)
1031
- ENUM_TO_NAME(BottomRightOrientation)
1032
- ENUM_TO_NAME(BottomLeftOrientation)
1033
- ENUM_TO_NAME(LeftTopOrientation)
1034
- ENUM_TO_NAME(RightTopOrientation)
1035
- ENUM_TO_NAME(RightBottomOrientation)
1036
- ENUM_TO_NAME(LeftBottomOrientation)
1037
- }
1038
-
1039
- return "UndefinedOrientation";
656
+ return Enum_find(Class_RenderingIntent, intent);
1040
657
  }
1041
658
 
1042
659
 
1043
660
  /**
1044
- * Construct an OrientationType enum object for the specified value.
661
+ * Returns a ResolutionType enum object for the specified value.
1045
662
  *
1046
663
  * No Ruby usage (internal function)
1047
664
  *
1048
- * @param type the OrientationType
1049
- * @return a new OrientationType enumerator
665
+ * @param type the ResolutionType
666
+ * @return a new ResolutionType enumerator
1050
667
  */
1051
668
  VALUE
1052
- OrientationType_new(OrientationType type)
669
+ ResolutionType_find(ResolutionType type)
1053
670
  {
1054
- const char *name = OrientationType_name(type);
1055
- return rm_enum_new(Class_OrientationType, ID2SYM(rb_intern(name)), INT2FIX(type));
671
+ return Enum_find(Class_ResolutionType, type);
1056
672
  }
1057
673
 
1058
674
 
1059
675
  /**
1060
- * Return the name of a RenderingIntent enum as a string.
676
+ * Return the string representation of a StorageType value.
1061
677
  *
1062
678
  * No Ruby usage (internal function)
1063
679
  *
1064
- * @param intent the RenderingIntent
680
+ * @param type the StorageType
1065
681
  * @return the name
1066
682
  */
1067
- static const char *
1068
- RenderingIntent_name(RenderingIntent intent)
683
+ const char *
684
+ StorageType_name(StorageType type)
1069
685
  {
1070
- switch(intent)
686
+ VALUE storage = Enum_find(Class_StorageType, type);
687
+ if (NIL_P(storage))
1071
688
  {
1072
- ENUM_TO_NAME(UndefinedIntent)
1073
- ENUM_TO_NAME(SaturationIntent)
1074
- ENUM_TO_NAME(PerceptualIntent)
1075
- ENUM_TO_NAME(AbsoluteIntent)
1076
- ENUM_TO_NAME(RelativeIntent)
689
+ return "UndefinedPixel";
1077
690
  }
1078
-
1079
- return "UndefinedIntent";
1080
- }
1081
-
1082
-
1083
- /**
1084
- * Construct an RenderingIntent enum object for the specified value.
1085
- *
1086
- * No Ruby usage (internal function)
1087
- *
1088
- * @param intent the RenderingIntent
1089
- * @return a new RenderingIntent enumerator
1090
- */
1091
- VALUE
1092
- RenderingIntent_new(RenderingIntent intent)
1093
- {
1094
- const char *name = RenderingIntent_name(intent);
1095
- return rm_enum_new(Class_RenderingIntent, ID2SYM(rb_intern(name)), INT2FIX(intent));
691
+ return rm_enum_to_cstr(storage);
1096
692
  }
1097
693
 
1098
694
 
1099
695
  /**
1100
- * Return the name of a ResolutionType enum as a string.
696
+ * Return the string representation of a StretchType value.
1101
697
  *
1102
698
  * No Ruby usage (internal function)
1103
699
  *
1104
- * @param type the ResolutionType
1105
- * @return the name
700
+ * @param stretch the StretchType value
701
+ * @return the string
1106
702
  */
1107
- static const char *
1108
- ResolutionType_name(ResolutionType type)
703
+ const char *
704
+ StretchType_name(StretchType type)
1109
705
  {
1110
- switch(type)
706
+ VALUE stretch = Enum_find(Class_StretchType, type);
707
+ if (NIL_P(stretch))
1111
708
  {
1112
- ENUM_TO_NAME(UndefinedResolution)
1113
- ENUM_TO_NAME(PixelsPerInchResolution)
1114
- ENUM_TO_NAME(PixelsPerCentimeterResolution)
709
+ return "UndefinedStretch";
1115
710
  }
1116
-
1117
- return "UndefinedResolution";
711
+ return rm_enum_to_cstr(stretch);
1118
712
  }
1119
713
 
1120
714
 
1121
715
  /**
1122
- * Construct an ResolutionType enum object for the specified value.
716
+ * Returns a StretchType enum for a specified StretchType value.
1123
717
  *
1124
718
  * No Ruby usage (internal function)
1125
719
  *
1126
- * @param type the ResolutionType
1127
- * @return a new ResolutionType enumerator
720
+ * @param stretch the C StretchType value
721
+ * @return a Ruby StretchType enum
1128
722
  */
1129
723
  VALUE
1130
- ResolutionType_new(ResolutionType type)
724
+ StretchType_find(StretchType stretch)
1131
725
  {
1132
- const char *name = ResolutionType_name(type);
1133
- return rm_enum_new(Class_ResolutionType, ID2SYM(rb_intern(name)), INT2FIX(type));
726
+ return Enum_find(Class_StretchType, stretch);
1134
727
  }
1135
728
 
1136
729
 
1137
730
  /**
1138
- * Return the string representation of a StorageType value.
731
+ * Return the string representation of a StyleType value.
1139
732
  *
1140
733
  * No Ruby usage (internal function)
1141
734
  *
1142
- * @param type the StorageType
1143
- * @return the name
735
+ * @param style the StyleType value
736
+ * @return the string
1144
737
  */
1145
738
  const char *
1146
- StorageType_name(StorageType type)
739
+ StyleType_name(StyleType type)
1147
740
  {
1148
- switch (type)
741
+ VALUE style = Enum_find(Class_StyleType, type);
742
+ if (NIL_P(style))
1149
743
  {
1150
- ENUM_TO_NAME(UndefinedPixel)
1151
- ENUM_TO_NAME(CharPixel)
1152
- ENUM_TO_NAME(DoublePixel)
1153
- ENUM_TO_NAME(FloatPixel)
1154
- ENUM_TO_NAME(IntegerPixel)
1155
- ENUM_TO_NAME(LongPixel)
1156
- ENUM_TO_NAME(QuantumPixel)
1157
- ENUM_TO_NAME(ShortPixel)
744
+ return "UndefinedStyle";
1158
745
  }
1159
-
1160
- return "UndefinedPixel";
746
+ return rm_enum_to_cstr(style);
1161
747
  }
1162
748
 
1163
749
 
1164
750
  /**
1165
- * Return the string representation of a VirtualPixelMethod value.
751
+ * Returns a StyleType enum for a specified StyleType value.
1166
752
  *
1167
753
  * No Ruby usage (internal function)
1168
754
  *
1169
- * @param method the VirtualPixelMethod
1170
- * @return the name
755
+ * @param style the C StyleType value
756
+ * @return a Ruby StyleType enum
1171
757
  */
1172
- static const char *
1173
- VirtualPixelMethod_name(VirtualPixelMethod method)
758
+ VALUE
759
+ StyleType_find(StyleType style)
1174
760
  {
1175
- switch (method)
1176
- {
1177
- ENUM_TO_NAME(UndefinedVirtualPixelMethod)
1178
- ENUM_TO_NAME(EdgeVirtualPixelMethod)
1179
- ENUM_TO_NAME(MirrorVirtualPixelMethod)
1180
- ENUM_TO_NAME(TileVirtualPixelMethod)
1181
- ENUM_TO_NAME(TransparentVirtualPixelMethod)
1182
- ENUM_TO_NAME(BackgroundVirtualPixelMethod)
1183
- ENUM_TO_NAME(DitherVirtualPixelMethod)
1184
- ENUM_TO_NAME(RandomVirtualPixelMethod)
1185
- ENUM_TO_NAME(ConstantVirtualPixelMethod)
1186
- ENUM_TO_NAME(MaskVirtualPixelMethod)
1187
- ENUM_TO_NAME(BlackVirtualPixelMethod)
1188
- ENUM_TO_NAME(GrayVirtualPixelMethod)
1189
- ENUM_TO_NAME(WhiteVirtualPixelMethod)
1190
- #if defined(HAVE_ENUM_HORIZONTALTILEVIRTUALPIXELMETHOD)
1191
- ENUM_TO_NAME(HorizontalTileVirtualPixelMethod)
1192
- #endif
1193
- #if defined(HAVE_ENUM_VERTICALTILEVIRTUALPIXELMETHOD)
1194
- ENUM_TO_NAME(VerticalTileVirtualPixelMethod)
1195
- #endif
1196
- #if defined(HAVE_ENUM_HORIZONTALTILEEDGEVIRTUALPIXELMETHOD)
1197
- ENUM_TO_NAME(HorizontalTileEdgeVirtualPixelMethod)
1198
- #endif
1199
- #if defined(HAVE_ENUM_VERTICALTILEEDGEVIRTUALPIXELMETHOD)
1200
- ENUM_TO_NAME(VerticalTileEdgeVirtualPixelMethod)
1201
- #endif
1202
- #if defined(HAVE_ENUM_CHECKERTILEVIRTUALPIXELMETHOD)
1203
- ENUM_TO_NAME(CheckerTileVirtualPixelMethod)
1204
- #endif
1205
- }
1206
-
1207
- return "UndefinedVirtualPixelMethod";
761
+ return Enum_find(Class_StyleType, style);
1208
762
  }
1209
763
 
1210
764
 
1211
765
  /**
1212
- * Construct a VirtualPixelMethod enum for a specified VirtualPixelMethod value.
766
+ * Returns a VirtualPixelMethod enum for a specified VirtualPixelMethod value.
1213
767
  *
1214
768
  * No Ruby usage (internal function)
1215
769
  *
@@ -1217,8 +771,7 @@ VirtualPixelMethod_name(VirtualPixelMethod method)
1217
771
  * @return a new VirtualPixelMethod enumerator
1218
772
  */
1219
773
  VALUE
1220
- VirtualPixelMethod_new(VirtualPixelMethod style)
774
+ VirtualPixelMethod_find(VirtualPixelMethod style)
1221
775
  {
1222
- const char *name = VirtualPixelMethod_name(style);
1223
- return rm_enum_new(Class_VirtualPixelMethod, ID2SYM(rb_intern(name)), INT2FIX(style));
776
+ return Enum_find(Class_VirtualPixelMethod, style);
1224
777
  }