rmagick 5.3.0 → 5.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
7
7
  *
8
- * @file rmenum.c
9
- * @version $Id: rmenum.c,v 1.9 2009/12/20 02:33:33 baror Exp $
8
+ * @file rmenum.cpp
9
+ * @version $Id: rmenum.cpp,v 1.9 2009/12/20 02:33:33 baror Exp $
10
10
  * @author Tim Hunter
11
11
  ******************************************************************************/
12
12
 
@@ -40,14 +40,14 @@ const rb_data_type_t rm_enum_data_type = {
40
40
  VALUE
41
41
  rm_define_enum_type(const char *tag)
42
42
  {
43
- VALUE class;
43
+ VALUE klass;
44
44
 
45
- class = rb_define_class_under(Module_Magick, tag, Class_Enum);\
45
+ klass = rb_define_class_under(Module_Magick, tag, Class_Enum);\
46
46
 
47
- rb_define_singleton_method(class, "values", Enum_type_values, 0);
48
- rb_define_method(class, "initialize", Enum_type_initialize, 2);
49
- rb_define_method(class, "inspect", Enum_type_inspect, 0);
50
- return class;
47
+ rb_define_singleton_method(klass, "values", RUBY_METHOD_FUNC(Enum_type_values), 0);
48
+ rb_define_method(klass, "initialize", RUBY_METHOD_FUNC(Enum_type_initialize), 2);
49
+ rb_define_method(klass, "inspect", RUBY_METHOD_FUNC(Enum_type_inspect), 0);
50
+ return klass;
51
51
  }
52
52
 
53
53
 
@@ -56,19 +56,19 @@ rm_define_enum_type(const char *tag)
56
56
  *
57
57
  * No Ruby usage (internal function)
58
58
  *
59
- * @param class the subclass
59
+ * @param klass the subclass
60
60
  * @param sym the symbol
61
61
  * @param val the value for the symbol
62
62
  * @return a new instance of class
63
63
  */
64
64
  VALUE
65
- rm_enum_new(VALUE class, VALUE sym, VALUE val)
65
+ rm_enum_new(VALUE klass, VALUE sym, VALUE val)
66
66
  {
67
67
  VALUE argv[2];
68
68
 
69
69
  argv[0] = sym;
70
70
  argv[1] = val;
71
- return rb_obj_freeze(rb_class_new_instance(2, argv, class));
71
+ return rb_obj_freeze(rb_class_new_instance(2, argv, klass));
72
72
  }
73
73
 
74
74
  /**
@@ -118,12 +118,12 @@ static void rm_enum_free(void *magick_enum)
118
118
  * @return [Magick::Enum] a new enumerator
119
119
  */
120
120
  VALUE
121
- Enum_alloc(VALUE class)
121
+ Enum_alloc(VALUE klass)
122
122
  {
123
123
  MagickEnum *magick_enum;
124
124
  VALUE enumr;
125
125
 
126
- enumr = TypedData_Make_Struct(class, MagickEnum, &rm_enum_data_type, magick_enum);
126
+ enumr = TypedData_Make_Struct(klass, MagickEnum, &rm_enum_data_type, magick_enum);
127
127
  rb_obj_freeze(enumr);
128
128
 
129
129
  return enumr;
@@ -141,11 +141,11 @@ Enum_case_eq(VALUE self, VALUE other)
141
141
  {
142
142
  if (CLASS_OF(self) == CLASS_OF(other))
143
143
  {
144
- MagickEnum *this, *that;
144
+ MagickEnum *self_enum, *other_enum;
145
145
 
146
- TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, this);
147
- TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, that);
148
- return this->val == that->val ? Qtrue : Qfalse;
146
+ TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, self_enum);
147
+ TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, other_enum);
148
+ return self_enum->val == other_enum->val ? Qtrue : Qfalse;
149
149
  }
150
150
 
151
151
  return Qfalse;
@@ -196,20 +196,20 @@ Enum_to_i(VALUE self)
196
196
  VALUE
197
197
  Enum_spaceship(VALUE self, VALUE other)
198
198
  {
199
- MagickEnum *this, *that;
199
+ MagickEnum *self_enum, *other_enum;
200
200
 
201
201
  if(CLASS_OF(self) != CLASS_OF(other)) {
202
202
  return Qnil;
203
203
  }
204
204
 
205
- TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, this);
206
- TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, that);
205
+ TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, self_enum);
206
+ TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, other_enum);
207
207
 
208
- if (this->val > that->val)
208
+ if (self_enum->val > other_enum->val)
209
209
  {
210
210
  return INT2FIX(1);
211
211
  }
212
- else if (this->val < that->val)
212
+ else if (self_enum->val < other_enum->val)
213
213
  {
214
214
  return INT2FIX(-1);
215
215
  }
@@ -224,25 +224,25 @@ Enum_spaceship(VALUE self, VALUE other)
224
224
  * @return [Magick::Enum] new Enum instance
225
225
  */
226
226
  VALUE
227
- Enum_bitwise_or(VALUE self, VALUE another)
227
+ Enum_bitwise_or(VALUE self, VALUE other)
228
228
  {
229
- VALUE new_enum, cls;
230
- MagickEnum *this, *that, *new_enum_data;
229
+ VALUE new_enum, klass;
230
+ MagickEnum *self_enum, *other_enum, *new_enum_data;
231
231
 
232
- cls = CLASS_OF(self);
233
- if (CLASS_OF(another) != cls)
232
+ klass = CLASS_OF(self);
233
+ if (CLASS_OF(other) != klass)
234
234
  {
235
- rb_raise(rb_eArgError, "Expected class %s but got %s", rb_class2name(cls), rb_class2name(CLASS_OF(another)));
235
+ rb_raise(rb_eArgError, "Expected class %s but got %s", rb_class2name(klass), rb_class2name(CLASS_OF(other)));
236
236
  }
237
237
 
238
- new_enum = Enum_alloc(cls);
238
+ new_enum = Enum_alloc(klass);
239
239
 
240
- TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, this);
241
- TypedData_Get_Struct(another, MagickEnum, &rm_enum_data_type, that);
240
+ TypedData_Get_Struct(self, MagickEnum, &rm_enum_data_type, self_enum);
241
+ TypedData_Get_Struct(other, MagickEnum, &rm_enum_data_type, other_enum);
242
242
  TypedData_Get_Struct(new_enum, MagickEnum, &rm_enum_data_type, new_enum_data);
243
243
 
244
- new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rb_id2name(this->id), rb_id2name(that->id)));
245
- new_enum_data->val = this->val | that->val;
244
+ new_enum_data->id = rb_to_id(rb_sprintf("%s|%s", rb_id2name(self_enum->id), rb_id2name(other_enum->id)));
245
+ new_enum_data->val = self_enum->val | other_enum->val;
246
246
 
247
247
  return new_enum;
248
248
  }
@@ -321,13 +321,13 @@ Enum_type_inspect(VALUE self)
321
321
  * @return [Magick::Enum] self
322
322
  */
323
323
  static VALUE
324
- Enum_type_values(VALUE class)
324
+ Enum_type_values(VALUE klass)
325
325
  {
326
326
  VALUE enumerators, copy;
327
327
  VALUE rv;
328
328
  int x;
329
329
 
330
- enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
330
+ enumerators = rb_cv_get(klass, ENUMERATORS_CLASS_VAR);
331
331
 
332
332
  if (rb_block_given_p())
333
333
  {
@@ -335,7 +335,7 @@ Enum_type_values(VALUE class)
335
335
  {
336
336
  rb_yield(rb_ary_entry(enumerators, x));
337
337
  }
338
- rv = class;
338
+ rv = klass;
339
339
  }
340
340
  else
341
341
  {
@@ -360,19 +360,19 @@ Enum_type_values(VALUE class)
360
360
  *
361
361
  * No Ruby usage (internal function)
362
362
  *
363
- * @param class the class type
363
+ * @param klass the class type
364
364
  * @param value the value for enum
365
365
  * @return a enumerator
366
366
  */
367
367
 
368
368
  VALUE
369
- Enum_find(VALUE class, int val)
369
+ Enum_find(VALUE klass, int val)
370
370
  {
371
371
  VALUE enumerators;
372
372
  MagickEnum *magick_enum;
373
373
  int x;
374
374
 
375
- enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
375
+ enumerators = rb_cv_get(klass, ENUMERATORS_CLASS_VAR);
376
376
  enumerators = rm_check_ary_type(enumerators);
377
377
 
378
378
  for (x = 0; x < RARRAY_LEN(enumerators); x++)
@@ -398,9 +398,9 @@ Enum_find(VALUE class, int val)
398
398
  * @return a new enumerator
399
399
  */
400
400
  VALUE
401
- ClassType_find(ClassType cls)
401
+ ClassType_find(ClassType klass)
402
402
  {
403
- return Enum_find(Class_ClassType, cls);
403
+ return Enum_find(Class_ClassType, klass);
404
404
  }
405
405
 
406
406
 
@@ -485,7 +485,7 @@ ComplianceType_find(ComplianceType compliance)
485
485
  if ((compliance & (SVGCompliance|X11Compliance|XPMCompliance))
486
486
  == (SVGCompliance|X11Compliance|XPMCompliance))
487
487
  {
488
- c = SVGCompliance|X11Compliance|XPMCompliance;
488
+ c = (ComplianceType)(SVGCompliance|X11Compliance|XPMCompliance);
489
489
  }
490
490
  else if (compliance & SVGCompliance)
491
491
  {
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * Changes since Nov. 2009 copyright &copy; by Benjamin Thomas and Omer Bar-or
7
7
  *
8
- * @file rmfill.c
9
- * @version $Id: rmfill.c,v 1.33 2009/12/20 02:33:33 baror Exp $
8
+ * @file rmfill.cpp
9
+ * @version $Id: rmfill.cpp,v 1.33 2009/12/20 02:33:33 baror Exp $
10
10
  * @author Tim Hunter
11
11
  ******************************************************************************/
12
12
 
@@ -86,11 +86,11 @@ GradientFill_memsize(const void *ptr)
86
86
  * @return [Magick::GradientFill] a new GradientFill object
87
87
  */
88
88
  VALUE
89
- GradientFill_alloc(VALUE class)
89
+ GradientFill_alloc(VALUE klass)
90
90
  {
91
91
  rm_GradientFill *fill;
92
92
 
93
- return TypedData_Make_Struct(class, rm_GradientFill, &rm_gradient_fill_data_type, fill);
93
+ return TypedData_Make_Struct(klass, rm_GradientFill, &rm_gradient_fill_data_type, fill);
94
94
  }
95
95
 
96
96
 
@@ -741,10 +741,10 @@ TextureFill_memsize(const void *ptr)
741
741
  * @return [Magick::TextureFill] a new TextureFill object
742
742
  */
743
743
  VALUE
744
- TextureFill_alloc(VALUE class)
744
+ TextureFill_alloc(VALUE klass)
745
745
  {
746
746
  rm_TextureFill *fill;
747
- return TypedData_Make_Struct(class, rm_TextureFill, &rm_texture_fill_data_type, fill);
747
+ return TypedData_Make_Struct(klass, rm_TextureFill, &rm_texture_fill_data_type, fill);
748
748
  }
749
749
 
750
750
  /**
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * Changes since Nov. 2009 copyright &copy; by Benjamin Thomas and Omer Bar-or
7
7
  *
8
- * @file rmilist.c
9
- * @version $Id: rmilist.c,v 1.94 2009/12/20 02:33:33 baror Exp $
8
+ * @file rmilist.cpp
9
+ * @version $Id: rmilist.cpp,v 1.94 2009/12/20 02:33:33 baror Exp $
10
10
  * @author Tim Hunter
11
11
  ******************************************************************************/
12
12
 
@@ -135,7 +135,7 @@ VALUE
135
135
  ImageList_append(VALUE self, VALUE stack_arg)
136
136
  {
137
137
  Image *images, *new_image;
138
- unsigned int stack;
138
+ MagickBooleanType stack;
139
139
  ExceptionInfo *exception;
140
140
 
141
141
  // Convert the image array to an image sequence.
@@ -143,7 +143,7 @@ ImageList_append(VALUE self, VALUE stack_arg)
143
143
 
144
144
  // If stack == true, stack rectangular images top-to-bottom,
145
145
  // otherwise left-to-right.
146
- stack = RTEST(stack_arg);
146
+ stack = (MagickBooleanType)RTEST(stack_arg);
147
147
 
148
148
  exception = AcquireExceptionInfo();
149
149
  GVL_STRUCT_TYPE(AppendImages) args = { images, stack, exception };
@@ -260,20 +260,20 @@ VALUE ImageList_combine(int argc, VALUE *argv, VALUE self)
260
260
  {
261
261
  case 5:
262
262
  if (colorspace == CMYKColorspace)
263
- channel |= AlphaChannel;
263
+ channel = (ChannelType)(channel | AlphaChannel);
264
264
  else
265
265
  rb_raise(rb_eArgError, "invalid number of images in this image list");
266
266
  case 4:
267
267
  if (colorspace == CMYKColorspace)
268
- channel |= IndexChannel;
268
+ channel = (ChannelType)(channel | IndexChannel);
269
269
  else
270
- channel |= AlphaChannel;
270
+ channel = (ChannelType)(channel | AlphaChannel);
271
271
  case 3:
272
- channel |= GreenChannel;
273
- channel |= BlueChannel;
272
+ channel = (ChannelType)(channel | GreenChannel);
273
+ channel = (ChannelType)(channel | BlueChannel);
274
274
  break;
275
275
  case 2:
276
- channel |= AlphaChannel;
276
+ channel = (ChannelType)(channel | AlphaChannel);
277
277
  break;
278
278
  case 1:
279
279
  break;
@@ -311,10 +311,10 @@ VALUE ImageList_combine(int argc, VALUE *argv, VALUE self)
311
311
  * @overload composite_layers(images)
312
312
  * @param images [Magick::ImageList] the source images
313
313
  *
314
- * @overload composite_layers(images, operator)
314
+ * @overload composite_layers(images, composite_op)
315
315
  * - Default operator is {Magick::OverCompositeOp}
316
316
  * @param images [Magick::ImageList] the source images
317
- * @param operator [Magick::CompositeOperator] the operator
317
+ * @param composite_op [Magick::CompositeOperator] the operator
318
318
  *
319
319
  * @return [Magick::ImageList] a new imagelist
320
320
  */
@@ -324,13 +324,13 @@ ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
324
324
  VALUE source_images;
325
325
  Image *dest, *source, *new_images;
326
326
  RectangleInfo geometry;
327
- CompositeOperator operator = OverCompositeOp;
327
+ CompositeOperator composite_op = OverCompositeOp;
328
328
  ExceptionInfo *exception;
329
329
 
330
330
  switch (argc)
331
331
  {
332
332
  case 2:
333
- VALUE_TO_ENUM(argv[1], operator, CompositeOperator);
333
+ VALUE_TO_ENUM(argv[1], composite_op, CompositeOperator);
334
334
  case 1:
335
335
  source_images = argv[0];
336
336
  break;
@@ -356,7 +356,7 @@ ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
356
356
  new_images->gravity, &geometry);
357
357
 
358
358
  exception = AcquireExceptionInfo();
359
- GVL_STRUCT_TYPE(CompositeLayers) args = { new_images, operator, source, geometry.x, geometry.y, exception };
359
+ GVL_STRUCT_TYPE(CompositeLayers) args = { new_images, composite_op, source, geometry.x, geometry.y, exception };
360
360
  CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeLayers), &args);
361
361
  rm_split(source);
362
362
  rm_check_exception(exception, new_images, DestroyOnError);
@@ -532,16 +532,16 @@ ImageList_morph(VALUE self, VALUE nimages)
532
532
  {
533
533
  Image *images, *new_images;
534
534
  ExceptionInfo *exception;
535
- long number_images;
535
+ size_t number_images;
536
536
 
537
537
 
538
538
  // Use a signed long so we can test for a negative argument.
539
- number_images = NUM2LONG(nimages);
540
- if (number_images <= 0)
539
+ if (NUM2LONG(nimages) <= 0)
541
540
  {
542
541
  rb_raise(rb_eArgError, "number of intervening images must be > 0");
543
542
  }
544
543
 
544
+ number_images = NUM2LONG(nimages);
545
545
  images = images_from_imagelist(self);
546
546
  exception = AcquireExceptionInfo();
547
547
  GVL_STRUCT_TYPE(MorphImages) args = { images, number_images, exception };
@@ -970,7 +970,7 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
970
970
  if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
971
971
  {
972
972
  VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
973
- quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
973
+ quantize_info.dither = (MagickBooleanType)(quantize_info.dither_method != NoDitherMethod);
974
974
  }
975
975
  else
976
976
  {
@@ -1155,7 +1155,7 @@ ImageList_to_blob(VALUE self)
1155
1155
  return Qnil;
1156
1156
  }
1157
1157
 
1158
- blob_str = rb_str_new(blob, (long)length);
1158
+ blob_str = rb_str_new((const char *)blob, (long)length);
1159
1159
  magick_free((void*)blob);
1160
1160
 
1161
1161
  RB_GC_GUARD(info_obj);
@@ -1193,7 +1193,9 @@ ImageList_write(VALUE self, VALUE file)
1193
1193
 
1194
1194
  // Ensure file is open - raise error if not
1195
1195
  GetOpenFile(file, fptr);
1196
- add_format_prefix(info, fptr->pathv);
1196
+ rb_io_check_writable(fptr);
1197
+
1198
+ add_format_prefix(info, rm_io_path(file));
1197
1199
  #if defined(_WIN32)
1198
1200
  SetImageInfoFile(info, NULL);
1199
1201
  #else