rmagick 4.2.6 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/ImageMagick6/devcontainer.json +1 -1
- data/.devcontainer/{ImageMagick7/devcontainer.json → devcontainer.json} +2 -2
- data/.devcontainer/setup-user.sh +1 -1
- data/.editorconfig +1 -1
- data/.github/workflows/ci.yml +87 -9
- data/.gitignore +4 -0
- data/.rubocop_todo.yml +16 -9
- data/.yardopts +1 -1
- data/CHANGELOG.md +130 -0
- data/Gemfile +20 -0
- data/README.md +10 -17
- data/Rakefile +63 -80
- data/before_install_linux.sh +3 -3
- data/before_install_osx.sh +6 -5
- data/ext/RMagick/extconf.rb +112 -52
- data/ext/RMagick/{rmagick.c → rmagick.cpp} +19 -22
- data/ext/RMagick/rmagick.h +88 -59
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/{rmdraw.c → rmdraw.cpp} +170 -159
- data/ext/RMagick/{rmenum.c → rmenum.cpp} +69 -50
- data/ext/RMagick/{rmfill.c → rmfill.cpp} +85 -24
- data/ext/RMagick/{rmilist.c → rmilist.cpp} +191 -93
- data/ext/RMagick/{rmimage.c → rmimage.cpp} +1543 -989
- data/ext/RMagick/{rminfo.c → rminfo.cpp} +140 -152
- data/ext/RMagick/{rmkinfo.c → rmkinfo.cpp} +46 -34
- data/ext/RMagick/rmmain.cpp +1923 -0
- data/ext/RMagick/{rmmontage.c → rmmontage.cpp} +50 -29
- data/ext/RMagick/{rmpixel.c → rmpixel.cpp} +108 -83
- data/ext/RMagick/{rmstruct.c → rmstruct.cpp} +6 -6
- data/ext/RMagick/{rmutil.c → rmutil.cpp} +62 -161
- data/lib/rmagick/version.rb +3 -1
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +76 -110
- data/lib/rvg/embellishable.rb +6 -2
- data/lib/rvg/misc.rb +7 -7
- data/lib/rvg/rvg.rb +2 -0
- data/lib/rvg/stretchable.rb +2 -2
- data/lib/rvg/transformable.rb +1 -1
- data/rmagick.gemspec +4 -13
- data/sig/rmagick/_draw_common_methods.rbs +64 -0
- data/sig/rmagick/_image_common_methods.rbs +389 -0
- data/sig/rmagick/draw.rbs +38 -0
- data/sig/rmagick/draw_attribute.rbs +28 -0
- data/sig/rmagick/enum.rbs +814 -0
- data/sig/rmagick/error.rbs +11 -0
- data/sig/rmagick/fill.rbs +21 -0
- data/sig/rmagick/geometry.rbs +14 -0
- data/sig/rmagick/image.rbs +194 -0
- data/sig/rmagick/image_list.rbs +181 -0
- data/sig/rmagick/iptc.rbs +101 -0
- data/sig/rmagick/kernel_info.rbs +12 -0
- data/sig/rmagick/optional_method_arguments.rbs +10 -0
- data/sig/rmagick/pixel.rbs +46 -0
- data/sig/rmagick/struct.rbs +90 -0
- data/sig/rmagick.rbs +43 -0
- data/sig/rvg/clippath.rbs +34 -0
- data/sig/rvg/container.rbs +78 -0
- data/sig/rvg/deep_equal.rbs +48 -0
- data/sig/rvg/describable.rbs +30 -0
- data/sig/rvg/embellishable.rbs +226 -0
- data/sig/rvg/misc.rbs +145 -0
- data/sig/rvg/paint.rbs +55 -0
- data/sig/rvg/pathdata.rbs +77 -0
- data/sig/rvg/rvg.rbs +125 -0
- data/sig/rvg/stretchable.rbs +56 -0
- data/sig/rvg/stylable.rbs +66 -0
- data/sig/rvg/text.rbs +118 -0
- data/sig/rvg/transformable.rbs +59 -0
- data/sig/rvg/units.rbs +33 -0
- metadata +59 -129
- data/.codeclimate.yml +0 -63
- data/deprecated/RMagick.rb +0 -6
- data/ext/RMagick/rmmain.c +0 -1951
data/ext/RMagick/rmagick.h
CHANGED
@@ -16,14 +16,21 @@
|
|
16
16
|
//! Suppress warnings about deprecated functions on Windows
|
17
17
|
#define _CRT_SECURE_NO_DEPRECATE 1
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
#include
|
22
|
-
|
23
|
-
|
24
|
-
#include <
|
25
|
-
#include
|
26
|
-
#include
|
19
|
+
// ruby.h contains a C++ template, which cannot be included in extern "C".
|
20
|
+
// Therefore, it includes the header in advance.
|
21
|
+
#include "ruby/defines.h"
|
22
|
+
|
23
|
+
extern "C" {
|
24
|
+
#include <assert.h>
|
25
|
+
#include <stdio.h>
|
26
|
+
#include <ctype.h>
|
27
|
+
#include <stdlib.h>
|
28
|
+
#include <math.h>
|
29
|
+
#include <sys/types.h>
|
30
|
+
#include "ruby.h"
|
31
|
+
#include "ruby/io.h"
|
32
|
+
#include "rmagick_gvl.h"
|
33
|
+
}
|
27
34
|
|
28
35
|
#if defined(__MINGW32__)
|
29
36
|
// Ruby defines wrong format specifiers for MinGW. So this defines original macro in here.
|
@@ -44,10 +51,6 @@
|
|
44
51
|
#endif
|
45
52
|
|
46
53
|
#if defined(__GNUC__)
|
47
|
-
#pragma GCC diagnostic push
|
48
|
-
#pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
|
49
|
-
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
50
|
-
|
51
54
|
#if __GNUC__ > 6
|
52
55
|
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
|
53
56
|
#endif
|
@@ -61,6 +64,11 @@
|
|
61
64
|
#undef PACKAGE_TARNAME
|
62
65
|
#undef WORDS_BIGENDIAN
|
63
66
|
|
67
|
+
#ifndef HAVE_RB_EXT_RACTOR_SAFE
|
68
|
+
#undef RUBY_TYPED_FROZEN_SHAREABLE
|
69
|
+
#define RUBY_TYPED_FROZEN_SHAREABLE 0
|
70
|
+
#endif
|
71
|
+
|
64
72
|
#include "extconf.h"
|
65
73
|
|
66
74
|
#if defined(IMAGEMAGICK_7)
|
@@ -90,8 +98,8 @@
|
|
90
98
|
|
91
99
|
//! Trace new image creation in bang methods
|
92
100
|
#define UPDATE_DATA_PTR(_obj_, _new_) \
|
93
|
-
do {
|
94
|
-
|
101
|
+
do { \
|
102
|
+
DATA_PTR(_obj_) = (void *)(_new_); \
|
95
103
|
} while(0)
|
96
104
|
|
97
105
|
|
@@ -310,7 +318,7 @@ typedef enum _QuantumExpressionOperator
|
|
310
318
|
|
311
319
|
|
312
320
|
/** This implements the "omitted storage class model" for external variables.
|
313
|
-
* (Ref: Harbison & Steele.) The rmmain.
|
321
|
+
* (Ref: Harbison & Steele.) The rmmain.cpp file defines MAIN, which causes
|
314
322
|
* the single defining declarations to be generated. No other source files
|
315
323
|
* define MAIN and therefore generate referencing declarations.
|
316
324
|
*/
|
@@ -325,6 +333,7 @@ typedef enum _QuantumExpressionOperator
|
|
325
333
|
* RMagick Module and Class VALUEs
|
326
334
|
*/
|
327
335
|
EXTERN VALUE Module_Magick;
|
336
|
+
EXTERN VALUE Module_DrawAttribute;
|
328
337
|
EXTERN VALUE Class_ImageList;
|
329
338
|
EXTERN VALUE Class_Info;
|
330
339
|
EXTERN VALUE Class_KernelInfo;
|
@@ -396,7 +405,6 @@ EXTERN VALUE Class_KernelInfoType;
|
|
396
405
|
/**
|
397
406
|
* Commonly-used IDs
|
398
407
|
*/
|
399
|
-
EXTERN ID rm_ID_trace_proc; /**< "@trace_proc" */
|
400
408
|
EXTERN ID rm_ID_call; /**< "call" */
|
401
409
|
EXTERN ID rm_ID_changed; /**< "changed" */
|
402
410
|
EXTERN ID rm_ID_cur_image; /**< "cur_image" */
|
@@ -411,7 +419,13 @@ EXTERN ID rm_ID_push; /**< "push" */
|
|
411
419
|
EXTERN ID rm_ID_values; /**< "values" */
|
412
420
|
EXTERN ID rm_ID_width; /**< "width" */
|
413
421
|
|
414
|
-
|
422
|
+
extern const rb_data_type_t rm_enum_data_type;
|
423
|
+
extern const rb_data_type_t rm_info_data_type;
|
424
|
+
extern const rb_data_type_t rm_image_data_type;
|
425
|
+
extern const rb_data_type_t rm_draw_data_type;
|
426
|
+
extern const rb_data_type_t rm_pixel_data_type;
|
427
|
+
extern const rb_data_type_t rm_montage_data_type;
|
428
|
+
extern const rb_data_type_t rm_kernel_info_data_type;
|
415
429
|
|
416
430
|
#if !defined(min)
|
417
431
|
#define min(a, b) ((a)<(b)?(a):(b)) /**< min of two values */
|
@@ -431,7 +445,7 @@ EXTERN unsigned long long rm_main_thread_id;
|
|
431
445
|
Define simple attribute accessor methods (boolean, int, string, and double types)
|
432
446
|
*/
|
433
447
|
#define C_boolean_to_R_boolean(attr) (attr) ? Qtrue : Qfalse /**< C boolean -> Ruby boolean */
|
434
|
-
#define R_boolean_to_C_boolean(attr) RTEST(attr) /**< C boolean <- Ruby boolean */
|
448
|
+
#define R_boolean_to_C_boolean(attr) (MagickBooleanType)RTEST(attr) /**< C boolean <- Ruby boolean */
|
435
449
|
#define C_int_to_R_int(attr) INT2FIX(attr) /**< C int -> Ruby int */
|
436
450
|
#define R_int_to_C_int(attr) NUM2INT(attr) /**< C int <- Ruby int */
|
437
451
|
#define C_long_to_R_long(attr) LONG2NUM(attr) /**< C long -> Ruby long */
|
@@ -443,47 +457,47 @@ EXTERN unsigned long long rm_main_thread_id;
|
|
443
457
|
#define R_dbl_to_C_dbl(attr) NUM2DBL(attr) /**< C double <- Ruby double */
|
444
458
|
|
445
459
|
//! define attribute reader
|
446
|
-
#define
|
460
|
+
#define IMPLEMENT_TYPED_ATTR_READER(klass, attr, type, data_type) \
|
447
461
|
{\
|
448
|
-
|
462
|
+
klass *ptr;\
|
449
463
|
if (rb_obj_is_kind_of(self, Class_Image) == Qtrue) {\
|
450
464
|
rm_check_destroyed(self); \
|
451
465
|
}\
|
452
|
-
|
466
|
+
TypedData_Get_Struct(self, klass, data_type, ptr);\
|
453
467
|
return C_##type##_to_R_##type(ptr->attr);\
|
454
468
|
}
|
455
469
|
|
456
470
|
//! define attribute reader when attribute name is different from the field name
|
457
|
-
#define
|
471
|
+
#define IMPLEMENT_TYPED_ATTR_READERF(klass, attr, field, type, data_type) \
|
458
472
|
{\
|
459
|
-
|
473
|
+
klass *ptr;\
|
460
474
|
rm_check_destroyed(self); \
|
461
|
-
|
475
|
+
TypedData_Get_Struct(self, klass, data_type, ptr);\
|
462
476
|
return C_##type##_to_R_##type(ptr->field);\
|
463
477
|
}
|
464
478
|
|
465
479
|
//! define attribute writer
|
466
|
-
#define
|
480
|
+
#define IMPLEMENT_TYPED_ATTR_WRITER(klass, attr, type, data_type) \
|
467
481
|
{\
|
468
|
-
|
482
|
+
klass *ptr;\
|
469
483
|
if (rb_obj_is_kind_of(self, Class_Image) == Qtrue) {\
|
470
484
|
rm_check_destroyed(self); \
|
471
485
|
}\
|
472
486
|
rb_check_frozen(self);\
|
473
|
-
|
487
|
+
TypedData_Get_Struct(self, klass, data_type, ptr);\
|
474
488
|
ptr->attr = R_##type##_to_C_##type(val);\
|
475
489
|
return val;\
|
476
490
|
}
|
477
491
|
|
478
492
|
//! define attribute writer when attribute name is different from the field name
|
479
|
-
#define
|
493
|
+
#define IMPLEMENT_TYPED_ATTR_WRITERF(klass, attr, field, type, data_type) \
|
480
494
|
{\
|
481
|
-
|
495
|
+
klass *ptr;\
|
482
496
|
if (rb_obj_is_kind_of(self, Class_Image) == Qtrue) {\
|
483
497
|
rm_check_destroyed(self); \
|
484
498
|
}\
|
485
499
|
rb_check_frozen(self);\
|
486
|
-
|
500
|
+
TypedData_Get_Struct(self, klass, data_type, ptr);\
|
487
501
|
ptr->field = R_##type##_to_C_##type(val);\
|
488
502
|
return self;\
|
489
503
|
}
|
@@ -493,15 +507,15 @@ EXTERN unsigned long long rm_main_thread_id;
|
|
493
507
|
* Declare attribute accessors
|
494
508
|
*/
|
495
509
|
//! declare attribute reader
|
496
|
-
#define ATTR_READER(
|
497
|
-
extern VALUE
|
510
|
+
#define ATTR_READER(klass, attr) \
|
511
|
+
extern VALUE klass##_##attr(VALUE);
|
498
512
|
//! declare attribute writer
|
499
|
-
#define ATTR_WRITER(
|
500
|
-
extern VALUE
|
513
|
+
#define ATTR_WRITER(klass, attr) \
|
514
|
+
extern VALUE klass##_##attr##_eq(VALUE, VALUE);
|
501
515
|
//! declare attribute accessor
|
502
|
-
#define ATTR_ACCESSOR(
|
503
|
-
ATTR_READER(
|
504
|
-
ATTR_WRITER(
|
516
|
+
#define ATTR_ACCESSOR(klass, attr) \
|
517
|
+
ATTR_READER(klass, attr)\
|
518
|
+
ATTR_WRITER(klass, attr)
|
505
519
|
|
506
520
|
|
507
521
|
//! Define a Magick module constant
|
@@ -513,7 +527,6 @@ EXTERN unsigned long long rm_main_thread_id;
|
|
513
527
|
#define DEF_CONSTV(constant, val) rb_define_const(Module_Magick, #constant, UINT2NUM(val))
|
514
528
|
#endif
|
515
529
|
|
516
|
-
|
517
530
|
//! Convert a Ruby enum constant back to a C enum member.
|
518
531
|
#define VALUE_TO_ENUM(value, e, type) \
|
519
532
|
do {\
|
@@ -521,7 +534,7 @@ EXTERN unsigned long long rm_main_thread_id;
|
|
521
534
|
if (CLASS_OF(value) != Class_##type)\
|
522
535
|
rb_raise(rb_eTypeError, "wrong enumeration type - expected %s, got %s", \
|
523
536
|
rb_class2name(Class_##type), rb_class2name(CLASS_OF(value)));\
|
524
|
-
|
537
|
+
TypedData_Get_Struct(value, MagickEnum, &rm_enum_data_type, magick_enum);\
|
525
538
|
e = (type)(magick_enum->val);\
|
526
539
|
} while(0)
|
527
540
|
|
@@ -534,11 +547,13 @@ EXTERN unsigned long long rm_main_thread_id;
|
|
534
547
|
// the same source file.
|
535
548
|
|
536
549
|
|
537
|
-
|
550
|
+
extern "C" {
|
551
|
+
|
552
|
+
// rmmain.cpp
|
538
553
|
extern void Init_RMagick2(void);
|
539
554
|
|
540
555
|
|
541
|
-
// rmagick.
|
556
|
+
// rmagick.cpp
|
542
557
|
extern VALUE Magick_colors(VALUE);
|
543
558
|
extern VALUE Magick_fonts(VALUE);
|
544
559
|
extern VALUE Magick_init_formats(VALUE);
|
@@ -547,7 +562,7 @@ extern VALUE Magick_set_cache_threshold(VALUE, VALUE);
|
|
547
562
|
extern VALUE Magick_set_log_event_mask(int, VALUE *, VALUE);
|
548
563
|
extern VALUE Magick_set_log_format(VALUE, VALUE);
|
549
564
|
|
550
|
-
// rmdraw.
|
565
|
+
// rmdraw.cpp
|
551
566
|
ATTR_WRITER(Draw, affine)
|
552
567
|
ATTR_WRITER(Draw, align)
|
553
568
|
ATTR_WRITER(Draw, border_color)
|
@@ -598,7 +613,7 @@ ATTR_WRITER(PolaroidOptions, shadow_color);
|
|
598
613
|
ATTR_WRITER(PolaroidOptions, border_color);
|
599
614
|
|
600
615
|
|
601
|
-
// rmmontage.
|
616
|
+
// rmmontage.cpp
|
602
617
|
ATTR_WRITER(Montage, background_color)
|
603
618
|
ATTR_WRITER(Montage, border_color)
|
604
619
|
ATTR_WRITER(Montage, border_width)
|
@@ -621,7 +636,7 @@ extern VALUE Montage_alloc(VALUE);
|
|
621
636
|
extern VALUE rm_montage_new(void);
|
622
637
|
|
623
638
|
|
624
|
-
// rmilist.
|
639
|
+
// rmilist.cpp
|
625
640
|
extern VALUE ImageList_animate(int, VALUE *, VALUE);
|
626
641
|
extern VALUE ImageList_append(VALUE, VALUE);
|
627
642
|
extern VALUE ImageList_average(VALUE);
|
@@ -643,7 +658,7 @@ extern VALUE ImageList_write(VALUE, VALUE);
|
|
643
658
|
extern VALUE rm_imagelist_from_images(Image *);
|
644
659
|
|
645
660
|
|
646
|
-
// rminfo.
|
661
|
+
// rminfo.cpp
|
647
662
|
ATTR_ACCESSOR(Info, antialias)
|
648
663
|
ATTR_ACCESSOR(Info, attenuate)
|
649
664
|
ATTR_ACCESSOR(Info, authenticate)
|
@@ -705,7 +720,7 @@ extern VALUE rm_info_new(void);
|
|
705
720
|
extern DisposeType rm_dispose_to_enum(const char *);
|
706
721
|
extern GravityType rm_gravity_to_enum(const char *);
|
707
722
|
|
708
|
-
// rmkinfo.
|
723
|
+
// rmkinfo.cpp
|
709
724
|
|
710
725
|
extern VALUE KernelInfo_alloc(VALUE);
|
711
726
|
|
@@ -718,7 +733,7 @@ extern VALUE KernelInfo_clone(VALUE);
|
|
718
733
|
extern VALUE KernelInfo_builtin(VALUE, VALUE, VALUE);
|
719
734
|
|
720
735
|
|
721
|
-
// rmimage.
|
736
|
+
// rmimage.cpp
|
722
737
|
ATTR_ACCESSOR(Image, background_color)
|
723
738
|
ATTR_READER(Image, base_columns)
|
724
739
|
ATTR_READER(Image, base_filename)
|
@@ -1019,10 +1034,9 @@ extern VALUE Image_write(VALUE, VALUE);
|
|
1019
1034
|
|
1020
1035
|
extern VALUE rm_image_new(Image *);
|
1021
1036
|
extern void rm_image_destroy(void *);
|
1022
|
-
extern void rm_trace_creation(Image *);
|
1023
1037
|
|
1024
1038
|
|
1025
|
-
// rmfill.
|
1039
|
+
// rmfill.cpp
|
1026
1040
|
extern VALUE GradientFill_alloc(VALUE);
|
1027
1041
|
extern VALUE GradientFill_initialize(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
|
1028
1042
|
extern VALUE GradientFill_fill(VALUE, VALUE);
|
@@ -1032,7 +1046,7 @@ extern VALUE TextureFill_initialize(VALUE, VALUE);
|
|
1032
1046
|
extern VALUE TextureFill_fill(VALUE, VALUE);
|
1033
1047
|
|
1034
1048
|
|
1035
|
-
// rmpixel.
|
1049
|
+
// rmpixel.cpp
|
1036
1050
|
|
1037
1051
|
|
1038
1052
|
ATTR_ACCESSOR(Pixel, red)
|
@@ -1043,7 +1057,6 @@ ATTR_ACCESSOR(Pixel, cyan)
|
|
1043
1057
|
ATTR_ACCESSOR(Pixel, magenta)
|
1044
1058
|
ATTR_ACCESSOR(Pixel, yellow)
|
1045
1059
|
ATTR_ACCESSOR(Pixel, black)
|
1046
|
-
extern void destroy_Pixel(Pixel *);
|
1047
1060
|
extern VALUE Pixel_alloc(VALUE);
|
1048
1061
|
extern VALUE Pixel_case_eq(VALUE, VALUE);
|
1049
1062
|
extern VALUE Pixel_clone(VALUE);
|
@@ -1064,7 +1077,7 @@ extern VALUE Pixel_to_hsla(VALUE);
|
|
1064
1077
|
extern VALUE Pixel_to_s(VALUE);
|
1065
1078
|
|
1066
1079
|
|
1067
|
-
// rmenum.
|
1080
|
+
// rmenum.cpp
|
1068
1081
|
extern VALUE Enum_alloc(VALUE);
|
1069
1082
|
extern VALUE Enum_initialize(VALUE, VALUE, VALUE);
|
1070
1083
|
extern VALUE Enum_to_s(VALUE);
|
@@ -1073,7 +1086,7 @@ extern VALUE Enum_spaceship(VALUE, VALUE);
|
|
1073
1086
|
extern VALUE Enum_bitwise_or(VALUE, VALUE);
|
1074
1087
|
extern VALUE Enum_case_eq(VALUE, VALUE);
|
1075
1088
|
extern VALUE Enum_type_initialize(VALUE, VALUE, VALUE);
|
1076
|
-
extern VALUE Enum_find(VALUE
|
1089
|
+
extern VALUE Enum_find(VALUE, int);
|
1077
1090
|
extern VALUE Enum_type_each(VALUE);
|
1078
1091
|
extern VALUE rm_enum_new(VALUE, VALUE, VALUE);
|
1079
1092
|
extern VALUE ClassType_find(ClassType);
|
@@ -1100,7 +1113,7 @@ extern const char *StyleType_name(StyleType);
|
|
1100
1113
|
extern VALUE VirtualPixelMethod_find(VirtualPixelMethod);
|
1101
1114
|
|
1102
1115
|
|
1103
|
-
// rmstruct.
|
1116
|
+
// rmstruct.cpp
|
1104
1117
|
extern VALUE ChromaticityInfo_to_s(VALUE);
|
1105
1118
|
extern VALUE ChromaticityInfo_new(ChromaticityInfo *);
|
1106
1119
|
extern void Color_to_PixelColor(PixelColor *, VALUE);
|
@@ -1135,7 +1148,7 @@ extern void Export_TypeInfo(TypeInfo *, VALUE);
|
|
1135
1148
|
extern VALUE Import_TypeMetric(TypeMetric *);
|
1136
1149
|
|
1137
1150
|
|
1138
|
-
// rmutil.
|
1151
|
+
// rmutil.cpp
|
1139
1152
|
extern VALUE ImageMagickError_initialize(int, VALUE *, VALUE);
|
1140
1153
|
extern void *magick_malloc(const size_t);
|
1141
1154
|
extern void *magick_safe_malloc(const size_t, const size_t);
|
@@ -1156,12 +1169,13 @@ extern void rm_check_ary_len(VALUE, long);
|
|
1156
1169
|
extern VALUE rm_check_ary_type(VALUE ary);
|
1157
1170
|
extern Image *rm_check_destroyed(VALUE);
|
1158
1171
|
extern Image *rm_check_frozen(VALUE);
|
1159
|
-
extern char *rm_str2cstr(VALUE,
|
1172
|
+
extern char *rm_str2cstr(VALUE, size_t *);
|
1160
1173
|
extern int rm_check_num2dbl(VALUE);
|
1161
1174
|
extern double rm_fuzz_to_dbl(VALUE);
|
1162
1175
|
extern Quantum rm_app2quantum(VALUE);
|
1163
1176
|
extern double rm_percentage(VALUE, double);
|
1164
|
-
extern double
|
1177
|
+
extern double rm_percentage2(VALUE, double, bool);
|
1178
|
+
extern double rm_str_to_pct(VALUE, bool);
|
1165
1179
|
extern VALUE rm_define_enum_type(const char *);
|
1166
1180
|
extern void rm_write_temp_image(Image *, char *, size_t);
|
1167
1181
|
extern void rm_delete_temp_image(char *);
|
@@ -1193,7 +1207,6 @@ typedef enum
|
|
1193
1207
|
extern void rm_check_exception(ExceptionInfo *, Image *, ErrorRetention);
|
1194
1208
|
extern void rm_ensure_result(Image *);
|
1195
1209
|
extern Image *rm_clone_image(Image *);
|
1196
|
-
extern MagickBooleanType rm_progress_monitor(const char *, const MagickOffsetType, const MagickSizeType, void *);
|
1197
1210
|
extern VALUE rm_exif_by_entry(Image *);
|
1198
1211
|
extern VALUE rm_exif_by_number(Image *);
|
1199
1212
|
extern void rm_get_optional_arguments(VALUE);
|
@@ -1202,10 +1215,26 @@ extern void rm_error_handler(const ExceptionType, const char *, const char *);
|
|
1202
1215
|
extern void rm_warning_handler(const ExceptionType, const char *, const char *);
|
1203
1216
|
extern MagickBooleanType rm_should_raise_exception(ExceptionInfo *, const ExceptionRetention);
|
1204
1217
|
extern void rm_raise_exception(ExceptionInfo *);
|
1205
|
-
extern
|
1218
|
+
extern VALUE rm_io_path(VALUE);
|
1206
1219
|
#if defined(IMAGEMAGICK_6)
|
1207
1220
|
extern void rm_check_image_exception(Image *, ErrorRetention);
|
1208
1221
|
#endif
|
1209
1222
|
|
1223
|
+
#if !defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_9_0)
|
1224
|
+
/* UnityAddKernelInfo() was private function until IM 6.9 */
|
1225
|
+
MagickExport void UnityAddKernelInfo(KernelInfo *kernel, const double scale);
|
1226
|
+
/* ScaleKernelInfo() was private function until IM 6.9 */
|
1227
|
+
MagickExport void ScaleKernelInfo(KernelInfo *kernel, const double scaling_factor, const GeometryFlags normalize_flags);
|
1210
1228
|
#endif
|
1211
1229
|
|
1230
|
+
#if (RUBY_VERSION_MAJOR == 2 && RUBY_VERSION_MINOR < 7)
|
1231
|
+
#define RESCUE_FUNC(func) (VALUE (*)(ANYARGS))(func)
|
1232
|
+
#define RESCUE_EXCEPTION_HANDLER_FUNC(func) (VALUE (*)(ANYARGS))(func)
|
1233
|
+
#else
|
1234
|
+
#define RESCUE_FUNC(func) (VALUE(*)(VALUE))(func)
|
1235
|
+
#define RESCUE_EXCEPTION_HANDLER_FUNC(func) (VALUE(*)(VALUE, VALUE))(func)
|
1236
|
+
#endif
|
1237
|
+
|
1238
|
+
} // extern "C"
|
1239
|
+
|
1240
|
+
#endif
|
@@ -0,0 +1,224 @@
|
|
1
|
+
#ifndef _RMAGICK_GVL_H_
|
2
|
+
#define _RMAGICK_GVL_H_
|
3
|
+
|
4
|
+
#include "ruby/thread.h"
|
5
|
+
|
6
|
+
typedef void *(gvl_function_t)(void *);
|
7
|
+
|
8
|
+
#define GVL_FUNC(name) name##_gvl
|
9
|
+
#define GVL_STRUCT_TYPE(name) name##_args_t
|
10
|
+
#define CALL_FUNC_WITHOUT_GVL(fp, args) \
|
11
|
+
rb_thread_call_without_gvl(fp, args, RUBY_UBF_PROCESS, NULL)
|
12
|
+
|
13
|
+
|
14
|
+
#define DEFINE_GVL_STRUCT1(name, type1) \
|
15
|
+
typedef struct { \
|
16
|
+
type1 arg1; \
|
17
|
+
} GVL_STRUCT_TYPE(name)
|
18
|
+
#define DEFINE_GVL_FUNC1(func_name, struct_name) \
|
19
|
+
static void *func_name##_gvl(void *p) \
|
20
|
+
{ \
|
21
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
22
|
+
return (void *)func_name(args->arg1); \
|
23
|
+
}
|
24
|
+
|
25
|
+
#define DEFINE_GVL_STUB1(name, type1) \
|
26
|
+
DEFINE_GVL_STRUCT1(name, type1); \
|
27
|
+
DEFINE_GVL_FUNC1(name, name)
|
28
|
+
|
29
|
+
|
30
|
+
#define DEFINE_GVL_STRUCT2(name, type1, type2) \
|
31
|
+
typedef struct { \
|
32
|
+
type1 arg1; \
|
33
|
+
type2 arg2; \
|
34
|
+
} GVL_STRUCT_TYPE(name)
|
35
|
+
#define DEFINE_GVL_FUNC2(func_name, struct_name) \
|
36
|
+
static void *func_name##_gvl(void *p) \
|
37
|
+
{ \
|
38
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
39
|
+
return (void *)func_name(args->arg1, args->arg2); \
|
40
|
+
}
|
41
|
+
|
42
|
+
#define DEFINE_GVL_STUB2(name, type1, type2) \
|
43
|
+
DEFINE_GVL_STRUCT2(name, type1, type2); \
|
44
|
+
DEFINE_GVL_FUNC2(name, name)
|
45
|
+
|
46
|
+
|
47
|
+
#define DEFINE_GVL_STRUCT3(name, type1, type2, type3) \
|
48
|
+
typedef struct { \
|
49
|
+
type1 arg1; \
|
50
|
+
type2 arg2; \
|
51
|
+
type3 arg3; \
|
52
|
+
} GVL_STRUCT_TYPE(name)
|
53
|
+
#define DEFINE_GVL_FUNC3(func_name, struct_name) \
|
54
|
+
static void *func_name##_gvl(void *p) \
|
55
|
+
{ \
|
56
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
57
|
+
return (void *)func_name(args->arg1, args->arg2, args->arg3); \
|
58
|
+
}
|
59
|
+
|
60
|
+
#define DEFINE_GVL_STUB3(name, type1, type2, type3) \
|
61
|
+
DEFINE_GVL_STRUCT3(name, type1, type2, type3); \
|
62
|
+
DEFINE_GVL_FUNC3(name, name)
|
63
|
+
|
64
|
+
|
65
|
+
#define DEFINE_GVL_STRUCT4(name, type1, type2, type3, type4) \
|
66
|
+
typedef struct { \
|
67
|
+
type1 arg1; \
|
68
|
+
type2 arg2; \
|
69
|
+
type3 arg3; \
|
70
|
+
type4 arg4; \
|
71
|
+
} GVL_STRUCT_TYPE(name)
|
72
|
+
#define DEFINE_GVL_FUNC4(func_name, struct_name) \
|
73
|
+
static void *func_name##_gvl(void *p) \
|
74
|
+
{ \
|
75
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
76
|
+
return (void *)func_name(args->arg1, args->arg2, args->arg3, args->arg4); \
|
77
|
+
}
|
78
|
+
|
79
|
+
#define DEFINE_GVL_STUB4(name, type1, type2, type3, type4) \
|
80
|
+
DEFINE_GVL_STRUCT4(name, type1, type2, type3, type4); \
|
81
|
+
DEFINE_GVL_FUNC4(name, name)
|
82
|
+
|
83
|
+
|
84
|
+
#define DEFINE_GVL_STRUCT5(name, type1, type2, type3, type4, type5) \
|
85
|
+
typedef struct { \
|
86
|
+
type1 arg1; \
|
87
|
+
type2 arg2; \
|
88
|
+
type3 arg3; \
|
89
|
+
type4 arg4; \
|
90
|
+
type5 arg5; \
|
91
|
+
} GVL_STRUCT_TYPE(name)
|
92
|
+
#define DEFINE_GVL_FUNC5(func_name, struct_name) \
|
93
|
+
static void *func_name##_gvl(void *p) \
|
94
|
+
{ \
|
95
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
96
|
+
return (void *)func_name(args->arg1, args->arg2, args->arg3, args->arg4, args->arg5); \
|
97
|
+
}
|
98
|
+
#define DEFINE_GVL_STUB5(name, type1, type2, type3, type4, type5) \
|
99
|
+
DEFINE_GVL_STRUCT5(name, type1, type2, type3, type4, type5); \
|
100
|
+
DEFINE_GVL_FUNC5(name, name)
|
101
|
+
|
102
|
+
|
103
|
+
#define DEFINE_GVL_STRUCT6(name, type1, type2, type3, type4, type5, type6) \
|
104
|
+
typedef struct { \
|
105
|
+
type1 arg1; \
|
106
|
+
type2 arg2; \
|
107
|
+
type3 arg3; \
|
108
|
+
type4 arg4; \
|
109
|
+
type5 arg5; \
|
110
|
+
type6 arg6; \
|
111
|
+
} GVL_STRUCT_TYPE(name)
|
112
|
+
#define DEFINE_GVL_FUNC6(func_name, struct_name) \
|
113
|
+
static void *func_name##_gvl(void *p) \
|
114
|
+
{ \
|
115
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
116
|
+
return (void *)func_name(args->arg1, args->arg2, args->arg3, args->arg4, args->arg5, args->arg6); \
|
117
|
+
}
|
118
|
+
#define DEFINE_GVL_STUB6(name, type1, type2, type3, type4, type5, type6) \
|
119
|
+
DEFINE_GVL_STRUCT6(name, type1, type2, type3, type4, type5, type6); \
|
120
|
+
DEFINE_GVL_FUNC6(name, name)
|
121
|
+
|
122
|
+
|
123
|
+
#define DEFINE_GVL_STRUCT7(name, type1, type2, type3, type4, type5, type6, type7) \
|
124
|
+
typedef struct { \
|
125
|
+
type1 arg1; \
|
126
|
+
type2 arg2; \
|
127
|
+
type3 arg3; \
|
128
|
+
type4 arg4; \
|
129
|
+
type5 arg5; \
|
130
|
+
type6 arg6; \
|
131
|
+
type7 arg7; \
|
132
|
+
} GVL_STRUCT_TYPE(name)
|
133
|
+
#define DEFINE_GVL_FUNC7(func_name, struct_name) \
|
134
|
+
static void *func_name##_gvl(void *p) \
|
135
|
+
{ \
|
136
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
137
|
+
return (void *)func_name(args->arg1, args->arg2, args->arg3, args->arg4, args->arg5, args->arg6, args->arg7); \
|
138
|
+
}
|
139
|
+
#define DEFINE_GVL_STUB7(name, type1, type2, type3, type4, type5, type6, type7) \
|
140
|
+
DEFINE_GVL_STRUCT7(name, type1, type2, type3, type4, type5, type6, type7); \
|
141
|
+
DEFINE_GVL_FUNC7(name, name)
|
142
|
+
|
143
|
+
|
144
|
+
#define DEFINE_GVL_STRUCT8(name, type1, type2, type3, type4, type5, type6, type7, type8) \
|
145
|
+
typedef struct { \
|
146
|
+
type1 arg1; \
|
147
|
+
type2 arg2; \
|
148
|
+
type3 arg3; \
|
149
|
+
type4 arg4; \
|
150
|
+
type5 arg5; \
|
151
|
+
type6 arg6; \
|
152
|
+
type7 arg7; \
|
153
|
+
type8 arg8; \
|
154
|
+
} GVL_STRUCT_TYPE(name)
|
155
|
+
#define DEFINE_GVL_FUNC8(func_name, struct_name) \
|
156
|
+
static void *func_name##_gvl(void *p) \
|
157
|
+
{ \
|
158
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
159
|
+
return (void *)func_name(args->arg1, args->arg2, args->arg3, args->arg4, args->arg5, args->arg6, args->arg7, args->arg8); \
|
160
|
+
}
|
161
|
+
#define DEFINE_GVL_STUB8(name, type1, type2, type3, type4, type5, type6, type7, type8) \
|
162
|
+
DEFINE_GVL_STRUCT8(name, type1, type2, type3, type4, type5, type6, type7, type8); \
|
163
|
+
DEFINE_GVL_FUNC8(name, name)
|
164
|
+
|
165
|
+
|
166
|
+
#define DEFINE_GVL_STRUCT9(name, type1, type2, type3, type4, type5, type6, type7, type8, type9) \
|
167
|
+
typedef struct { \
|
168
|
+
type1 arg1; \
|
169
|
+
type2 arg2; \
|
170
|
+
type3 arg3; \
|
171
|
+
type4 arg4; \
|
172
|
+
type5 arg5; \
|
173
|
+
type6 arg6; \
|
174
|
+
type7 arg7; \
|
175
|
+
type8 arg8; \
|
176
|
+
type9 arg9; \
|
177
|
+
} GVL_STRUCT_TYPE(name)
|
178
|
+
#define DEFINE_GVL_FUNC9(func_name, struct_name) \
|
179
|
+
static void *func_name##_gvl(void *p) \
|
180
|
+
{ \
|
181
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
182
|
+
return (void *)func_name(args->arg1, args->arg2, args->arg3, args->arg4, args->arg5, args->arg6, args->arg7, args->arg8, args->arg9); \
|
183
|
+
}
|
184
|
+
#define DEFINE_GVL_STUB9(name, type1, type2, type3, type4, type5, type6, type7, type8, type9) \
|
185
|
+
DEFINE_GVL_STRUCT9(name, type1, type2, type3, type4, type5, type6, type7, type8, type9); \
|
186
|
+
DEFINE_GVL_FUNC9(name, name)
|
187
|
+
|
188
|
+
|
189
|
+
#define DEFINE_GVL_VOID_FUNC2(func_name, struct_name) \
|
190
|
+
static void *func_name##_gvl(void *p) \
|
191
|
+
{ \
|
192
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
193
|
+
func_name(args->arg1, args->arg2); \
|
194
|
+
return NULL; \
|
195
|
+
}
|
196
|
+
#define DEFINE_GVL_VOID_STUB2(name, type1, type2) \
|
197
|
+
DEFINE_GVL_STRUCT2(name, type1, type2); \
|
198
|
+
DEFINE_GVL_VOID_FUNC2(name, name)
|
199
|
+
|
200
|
+
|
201
|
+
#define DEFINE_GVL_VOID_FUNC3(func_name, struct_name) \
|
202
|
+
static void *func_name##_gvl(void *p) \
|
203
|
+
{ \
|
204
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
205
|
+
func_name(args->arg1, args->arg2, args->arg3); \
|
206
|
+
return NULL; \
|
207
|
+
}
|
208
|
+
#define DEFINE_GVL_VOID_STUB3(name, type1, type2, type3) \
|
209
|
+
DEFINE_GVL_STRUCT3(name, type1, type2, type3); \
|
210
|
+
DEFINE_GVL_VOID_FUNC3(name, name)
|
211
|
+
|
212
|
+
|
213
|
+
#define DEFINE_GVL_VOID_FUNC6(func_name, struct_name) \
|
214
|
+
static void *func_name##_gvl(void *p) \
|
215
|
+
{ \
|
216
|
+
GVL_STRUCT_TYPE(struct_name) *args = (GVL_STRUCT_TYPE(struct_name) *)p; \
|
217
|
+
func_name(args->arg1, args->arg2, args->arg3, args->arg4, args->arg5, args->arg6); \
|
218
|
+
return NULL; \
|
219
|
+
}
|
220
|
+
#define DEFINE_GVL_VOID_STUB6(name, type1, type2, type3, type4, type5, type6) \
|
221
|
+
DEFINE_GVL_STRUCT6(name, type1, type2, type3, type4, type5, type6); \
|
222
|
+
DEFINE_GVL_VOID_FUNC6(name, name)
|
223
|
+
|
224
|
+
#endif
|