| @@ -1,835 +1,861 @@ | | | @@ -1,835 +1,861 @@ |
1 | $NetBSD: patch-aa,v 1.2 2014/03/17 14:12:10 taca Exp $ | | 1 | $NetBSD: patch-aa,v 1.3 2021/02/14 14:59:38 taca Exp $ |
2 | | | 2 | |
3 | Support both Ruby 1.8 and Ruby 1.9. | | 3 | Support modern Ruby API. |
4 | | | 4 | |
5 | --- GD.c.orig 2014-03-11 11:19:58.000000000 +0000 | | 5 | --- GD.c.orig 2021-01-11 07:41:51.880067934 +0000 |
6 | +++ GD.c | | 6 | +++ GD.c |
7 | @@ -11,7 +11,23 @@ | | 7 | @@ -11,6 +11,9 @@ |
8 | **************************************************************/ | | 8 | **************************************************************/ |
9 | #include "ruby.h" | | 9 | #include "ruby.h" |
10 | +#ifdef HAVE_RUBY_IO_H /* Ruby 1.9 and later */ | | 10 | -#include "rubyio.h" |
11 | + | | 11 | -#include "version.h" |
12 | +#include "ruby/io.h" | | 12 | +#include "ruby/io.h" |
13 | +#include "ruby/version.h" | | 13 | +#include "ruby/version.h" |
14 | + | | 14 | + |
15 | +#define RB_IO_PATH(iot) (RSTRING_PTR((iot)->pathv)) | | 15 | +#define RB_IO_PATH(iot) (RSTRING_PTR((iot)->pathv)) |
16 | +#define RB_IO_FILE(iot) rb_io_stdio_file((iot)) | | 16 | +#define RB_IO_FILE(iot) rb_io_stdio_file((iot)) |
17 | + | | | |
18 | +#else /* Ruby 1.8.x */ | | | |
19 | + | | | |
20 | #include "rubyio.h" | | | |
21 | #include "version.h" | | | |
22 | | | 17 | |
23 | +#define rb_io_stdio_file(iot) ((iot)->f) | | | |
24 | +#define RB_IO_PATH(iot) ((iot)->path) | | | |
25 | +#define RB_IO_FILE(iot) (((iot)->f2)? (iot)->f2: (iot)->f) | | | |
26 | + | | | |
27 | +#endif | | | |
28 | + | | | |
29 | #include "gd.h" | | 18 | #include "gd.h" |
30 | #include "gdfontg.h" /* giant */ | | 19 | @@ -63,17 +66,17 @@ img_from_pngfname(klass, fname) |
31 | @@ -63,17 +79,17 @@ img_from_pngfname(klass, fname) | | | |
32 | { | | 20 | { |
33 | VALUE f; | | 21 | VALUE f; |
34 | - OpenFile *fptr; | | 22 | - OpenFile *fptr; |
35 | + rb_io_t *fptr; | | 23 | + rb_io_t *fptr; |
36 | gdImagePtr iptr; | | 24 | gdImagePtr iptr; |
37 | | | 25 | |
38 | Check_Type(fname, T_STRING); | | 26 | Check_Type(fname, T_STRING); |
39 | | | 27 | |
40 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 28 | - f = rb_file_open(STR2CSTR(fname), "r"); |
41 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 29 | + f = rb_file_open(StringValuePtr(fname), "r"); |
42 | rb_io_binmode(f); | | 30 | rb_io_binmode(f); |
43 | GetOpenFile(f, fptr); | | 31 | GetOpenFile(f, fptr); |
44 | rb_io_check_readable(fptr); | | 32 | rb_io_check_readable(fptr); |
45 | | | 33 | |
46 | - iptr = gdImageCreateFromPng(fptr->f); | | 34 | - iptr = gdImageCreateFromPng(fptr->f); |
47 | + iptr = gdImageCreateFromPng(rb_io_stdio_file(fptr)); | | 35 | + iptr = gdImageCreateFromPng(rb_io_stdio_file(fptr)); |
48 | if (!iptr) | | 36 | if (!iptr) |
49 | - rb_raise(rb_eArgError, "%s is not a valid PNG File", fptr->path); | | 37 | - rb_raise(rb_eArgError, "%s is not a valid PNG File", fptr->path); |
50 | + rb_raise(rb_eArgError, "%s is not a valid PNG File", RB_IO_PATH(fptr)); | | 38 | + rb_raise(rb_eArgError, "%s is not a valid PNG File", RB_IO_PATH(fptr)); |
51 | | | 39 | |
52 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 40 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
53 | @@ -85,5 +101,5 @@ img_from_png(klass, f) | | 41 | @@ -85,5 +88,5 @@ img_from_png(klass, f) |
54 | VALUE klass, f; | | 42 | VALUE klass, f; |
55 | { | | 43 | { |
56 | - OpenFile *fptr; | | 44 | - OpenFile *fptr; |
57 | + rb_io_t *fptr; | | 45 | + rb_io_t *fptr; |
58 | gdImagePtr iptr; | | 46 | gdImagePtr iptr; |
59 | | | 47 | |
60 | @@ -93,7 +109,7 @@ img_from_png(klass, f) | | 48 | @@ -93,7 +96,7 @@ img_from_png(klass, f) |
61 | rb_io_check_readable(fptr); | | 49 | rb_io_check_readable(fptr); |
62 | | | 50 | |
63 | - iptr = gdImageCreateFromPng(fptr->f); | | 51 | - iptr = gdImageCreateFromPng(fptr->f); |
64 | + iptr = gdImageCreateFromPng(rb_io_stdio_file(fptr)); | | 52 | + iptr = gdImageCreateFromPng(rb_io_stdio_file(fptr)); |
65 | if (!iptr) | | 53 | if (!iptr) |
66 | - rb_raise(rb_eArgError, "%s is not a valid PNG File", fptr->path); | | 54 | - rb_raise(rb_eArgError, "%s is not a valid PNG File", fptr->path); |
67 | + rb_raise(rb_eArgError, "%s is not a valid PNG File", RB_IO_PATH(fptr)); | | 55 | + rb_raise(rb_eArgError, "%s is not a valid PNG File", RB_IO_PATH(fptr)); |
68 | | | 56 | |
69 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 57 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
70 | @@ -106,17 +122,17 @@ img_from_giffname(klass, fname) | | 58 | @@ -106,17 +109,17 @@ img_from_giffname(klass, fname) |
71 | { | | 59 | { |
72 | VALUE f; | | 60 | VALUE f; |
73 | - OpenFile *fptr; | | 61 | - OpenFile *fptr; |
74 | + rb_io_t *fptr; | | 62 | + rb_io_t *fptr; |
75 | gdImagePtr iptr; | | 63 | gdImagePtr iptr; |
76 | | | 64 | |
77 | Check_Type(fname, T_STRING); | | 65 | Check_Type(fname, T_STRING); |
78 | | | 66 | |
79 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 67 | - f = rb_file_open(STR2CSTR(fname), "r"); |
80 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 68 | + f = rb_file_open(StringValuePtr(fname), "r"); |
81 | rb_io_binmode(f); | | 69 | rb_io_binmode(f); |
82 | GetOpenFile(f, fptr); | | 70 | GetOpenFile(f, fptr); |
83 | rb_io_check_readable(fptr); | | 71 | rb_io_check_readable(fptr); |
84 | | | 72 | |
85 | - iptr = gdImageCreateFromGif(fptr->f); | | 73 | - iptr = gdImageCreateFromGif(fptr->f); |
86 | + iptr = gdImageCreateFromGif(rb_io_stdio_file(fptr)); | | 74 | + iptr = gdImageCreateFromGif(rb_io_stdio_file(fptr)); |
87 | if (!iptr) | | 75 | if (!iptr) |
88 | - rb_raise(rb_eArgError, "%s is not a valid GIF File", fptr->path); | | 76 | - rb_raise(rb_eArgError, "%s is not a valid GIF File", fptr->path); |
89 | + rb_raise(rb_eArgError, "%s is not a valid GIF File", RB_IO_PATH(fptr)); | | 77 | + rb_raise(rb_eArgError, "%s is not a valid GIF File", RB_IO_PATH(fptr)); |
90 | | | 78 | |
91 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 79 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
92 | @@ -127,5 +143,5 @@ img_from_gif(klass, f) | | 80 | @@ -127,5 +130,5 @@ img_from_gif(klass, f) |
93 | VALUE klass, f; | | 81 | VALUE klass, f; |
94 | { | | 82 | { |
95 | - OpenFile *fptr; | | 83 | - OpenFile *fptr; |
96 | + rb_io_t *fptr; | | 84 | + rb_io_t *fptr; |
97 | gdImagePtr iptr; | | 85 | gdImagePtr iptr; |
98 | | | 86 | |
99 | @@ -135,7 +151,7 @@ img_from_gif(klass, f) | | 87 | @@ -135,7 +138,7 @@ img_from_gif(klass, f) |
100 | rb_io_check_readable(fptr); | | 88 | rb_io_check_readable(fptr); |
101 | | | 89 | |
102 | - iptr = gdImageCreateFromGif(fptr->f); | | 90 | - iptr = gdImageCreateFromGif(fptr->f); |
103 | + iptr = gdImageCreateFromGif(rb_io_stdio_file(fptr)); | | 91 | + iptr = gdImageCreateFromGif(rb_io_stdio_file(fptr)); |
104 | if (!iptr) | | 92 | if (!iptr) |
105 | - rb_raise(rb_eArgError, "%s is not a valid GIF File", fptr->path); | | 93 | - rb_raise(rb_eArgError, "%s is not a valid GIF File", fptr->path); |
106 | + rb_raise(rb_eArgError, "%s is not a valid GIF File", RB_IO_PATH(fptr)); | | 94 | + rb_raise(rb_eArgError, "%s is not a valid GIF File", RB_IO_PATH(fptr)); |
107 | | | 95 | |
108 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 96 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
109 | @@ -148,17 +164,17 @@ img_from_gdfname(klass, fname) | | 97 | @@ -148,17 +151,17 @@ img_from_gdfname(klass, fname) |
110 | { | | 98 | { |
111 | VALUE f; | | 99 | VALUE f; |
112 | - OpenFile *fptr; | | 100 | - OpenFile *fptr; |
113 | + rb_io_t *fptr; | | 101 | + rb_io_t *fptr; |
114 | gdImagePtr iptr; | | 102 | gdImagePtr iptr; |
115 | | | 103 | |
116 | Check_Type(fname, T_STRING); | | 104 | Check_Type(fname, T_STRING); |
117 | | | 105 | |
118 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 106 | - f = rb_file_open(STR2CSTR(fname), "r"); |
119 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 107 | + f = rb_file_open(StringValuePtr(fname), "r"); |
120 | rb_io_binmode(f); | | 108 | rb_io_binmode(f); |
121 | GetOpenFile(f, fptr); | | 109 | GetOpenFile(f, fptr); |
122 | rb_io_check_readable(fptr); | | 110 | rb_io_check_readable(fptr); |
123 | | | 111 | |
124 | - iptr = gdImageCreateFromGd(fptr->f); | | 112 | - iptr = gdImageCreateFromGd(fptr->f); |
125 | + iptr = gdImageCreateFromGd(rb_io_stdio_file(fptr)); | | 113 | + iptr = gdImageCreateFromGd(rb_io_stdio_file(fptr)); |
126 | if (!iptr) | | 114 | if (!iptr) |
127 | - rb_raise(rb_eArgError, "%s is not a valid Gd File", fptr->path); | | 115 | - rb_raise(rb_eArgError, "%s is not a valid Gd File", fptr->path); |
128 | + rb_raise(rb_eArgError, "%s is not a valid Gd File", RB_IO_PATH(fptr)); | | 116 | + rb_raise(rb_eArgError, "%s is not a valid Gd File", RB_IO_PATH(fptr)); |
129 | | | 117 | |
130 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 118 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
131 | @@ -169,5 +185,5 @@ img_from_gd(klass, f) | | 119 | @@ -169,5 +172,5 @@ img_from_gd(klass, f) |
132 | VALUE klass, f; | | 120 | VALUE klass, f; |
133 | { | | 121 | { |
134 | - OpenFile *fptr; | | 122 | - OpenFile *fptr; |
135 | + rb_io_t *fptr; | | 123 | + rb_io_t *fptr; |
136 | gdImagePtr iptr; | | 124 | gdImagePtr iptr; |
137 | | | 125 | |
138 | @@ -177,7 +193,7 @@ img_from_gd(klass, f) | | 126 | @@ -177,7 +180,7 @@ img_from_gd(klass, f) |
139 | rb_io_check_readable(fptr); | | 127 | rb_io_check_readable(fptr); |
140 | | | 128 | |
141 | - iptr = gdImageCreateFromGd(fptr->f); | | 129 | - iptr = gdImageCreateFromGd(fptr->f); |
142 | + iptr = gdImageCreateFromGd(rb_io_stdio_file(fptr)); | | 130 | + iptr = gdImageCreateFromGd(rb_io_stdio_file(fptr)); |
143 | if (!iptr) | | 131 | if (!iptr) |
144 | - rb_raise(rb_eArgError, "%s is not a valid Gd File", fptr->path); | | 132 | - rb_raise(rb_eArgError, "%s is not a valid Gd File", fptr->path); |
145 | + rb_raise(rb_eArgError, "%s is not a valid Gd File", RB_IO_PATH(fptr)); | | 133 | + rb_raise(rb_eArgError, "%s is not a valid Gd File", RB_IO_PATH(fptr)); |
146 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 134 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
147 | } | | 135 | } |
148 | @@ -188,17 +204,17 @@ img_from_gd2fname(klass, fname) | | 136 | @@ -188,17 +191,17 @@ img_from_gd2fname(klass, fname) |
149 | { | | 137 | { |
150 | VALUE f; | | 138 | VALUE f; |
151 | - OpenFile *fptr; | | 139 | - OpenFile *fptr; |
152 | + rb_io_t *fptr; | | 140 | + rb_io_t *fptr; |
153 | gdImagePtr iptr; | | 141 | gdImagePtr iptr; |
154 | | | 142 | |
155 | Check_Type(fname, T_STRING); | | 143 | Check_Type(fname, T_STRING); |
156 | | | 144 | |
157 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 145 | - f = rb_file_open(STR2CSTR(fname), "r"); |
158 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 146 | + f = rb_file_open(StringValuePtr(fname), "r"); |
159 | rb_io_binmode(f); | | 147 | rb_io_binmode(f); |
160 | GetOpenFile(f, fptr); | | 148 | GetOpenFile(f, fptr); |
161 | rb_io_check_readable(fptr); | | 149 | rb_io_check_readable(fptr); |
162 | | | 150 | |
163 | - iptr = gdImageCreateFromGd2(fptr->f); | | 151 | - iptr = gdImageCreateFromGd2(fptr->f); |
164 | + iptr = gdImageCreateFromGd2(rb_io_stdio_file(fptr)); | | 152 | + iptr = gdImageCreateFromGd2(rb_io_stdio_file(fptr)); |
165 | if (!iptr) | | 153 | if (!iptr) |
166 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); | | 154 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); |
167 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); | | 155 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); |
168 | | | 156 | |
169 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 157 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
170 | @@ -209,5 +225,5 @@ img_from_gd2(klass, f) | | 158 | @@ -209,5 +212,5 @@ img_from_gd2(klass, f) |
171 | VALUE klass, f; | | 159 | VALUE klass, f; |
172 | { | | 160 | { |
173 | - OpenFile *fptr; | | 161 | - OpenFile *fptr; |
174 | + rb_io_t *fptr; | | 162 | + rb_io_t *fptr; |
175 | gdImagePtr iptr; | | 163 | gdImagePtr iptr; |
176 | | | 164 | |
177 | @@ -217,7 +233,7 @@ img_from_gd2(klass, f) | | 165 | @@ -217,7 +220,7 @@ img_from_gd2(klass, f) |
178 | rb_io_check_readable(fptr); | | 166 | rb_io_check_readable(fptr); |
179 | | | 167 | |
180 | - iptr = gdImageCreateFromGd2(fptr->f); | | 168 | - iptr = gdImageCreateFromGd2(fptr->f); |
181 | + iptr = gdImageCreateFromGd2(rb_io_stdio_file(fptr)); | | 169 | + iptr = gdImageCreateFromGd2(rb_io_stdio_file(fptr)); |
182 | if (!iptr) | | 170 | if (!iptr) |
183 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); | | 171 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); |
184 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); | | 172 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); |
185 | | | 173 | |
186 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 174 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
187 | @@ -229,18 +245,18 @@ img_from_gd2_partfname(klass, fname, src | | 175 | @@ -229,18 +232,18 @@ img_from_gd2_partfname(klass, fname, src |
188 | { | | 176 | { |
189 | VALUE f; | | 177 | VALUE f; |
190 | - OpenFile *fptr; | | 178 | - OpenFile *fptr; |
191 | + rb_io_t *fptr; | | 179 | + rb_io_t *fptr; |
192 | gdImagePtr iptr; | | 180 | gdImagePtr iptr; |
193 | | | 181 | |
194 | Check_Type(fname, T_STRING); | | 182 | Check_Type(fname, T_STRING); |
195 | | | 183 | |
196 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 184 | - f = rb_file_open(STR2CSTR(fname), "r"); |
197 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 185 | + f = rb_file_open(StringValuePtr(fname), "r"); |
198 | rb_io_binmode(f); | | 186 | rb_io_binmode(f); |
199 | GetOpenFile(f, fptr); | | 187 | GetOpenFile(f, fptr); |
200 | rb_io_check_readable(fptr); | | 188 | rb_io_check_readable(fptr); |
201 | | | 189 | |
202 | - iptr = gdImageCreateFromGd2Part(fptr->f, NUM2INT(srcx), | | 190 | - iptr = gdImageCreateFromGd2Part(fptr->f, NUM2INT(srcx), |
203 | + iptr = gdImageCreateFromGd2Part(rb_io_stdio_file(fptr), NUM2INT(srcx), | | 191 | + iptr = gdImageCreateFromGd2Part(rb_io_stdio_file(fptr), NUM2INT(srcx), |
204 | NUM2INT(srcy), NUM2INT(w), NUM2INT(h)); | | 192 | NUM2INT(srcy), NUM2INT(w), NUM2INT(h)); |
205 | if (!iptr) | | 193 | if (!iptr) |
206 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); | | 194 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); |
207 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); | | 195 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); |
208 | | | 196 | |
209 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 197 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
210 | @@ -251,5 +267,5 @@ img_from_gd2_part(klass, f, srcx, srcy, | | 198 | @@ -251,5 +254,5 @@ img_from_gd2_part(klass, f, srcx, srcy, |
211 | VALUE klass, f, srcx, srcy, w, h; | | 199 | VALUE klass, f, srcx, srcy, w, h; |
212 | { | | 200 | { |
213 | - OpenFile *fptr; | | 201 | - OpenFile *fptr; |
214 | + rb_io_t *fptr; | | 202 | + rb_io_t *fptr; |
215 | gdImagePtr iptr; | | 203 | gdImagePtr iptr; |
216 | | | 204 | |
217 | @@ -259,8 +275,8 @@ img_from_gd2_part(klass, f, srcx, srcy, | | 205 | @@ -259,8 +262,8 @@ img_from_gd2_part(klass, f, srcx, srcy, |
218 | rb_io_check_readable(fptr); | | 206 | rb_io_check_readable(fptr); |
219 | | | 207 | |
220 | - iptr = gdImageCreateFromGd2Part(fptr->f, NUM2INT(srcx), | | 208 | - iptr = gdImageCreateFromGd2Part(fptr->f, NUM2INT(srcx), |
221 | + iptr = gdImageCreateFromGd2Part(rb_io_stdio_file(fptr), NUM2INT(srcx), | | 209 | + iptr = gdImageCreateFromGd2Part(rb_io_stdio_file(fptr), NUM2INT(srcx), |
222 | NUM2INT(srcy), NUM2INT(w), NUM2INT(h)); | | 210 | NUM2INT(srcy), NUM2INT(w), NUM2INT(h)); |
223 | if (!iptr) | | 211 | if (!iptr) |
224 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); | | 212 | - rb_raise(rb_eArgError, "%s is not a valid Gd2 File", fptr->path); |
225 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); | | 213 | + rb_raise(rb_eArgError, "%s is not a valid Gd2 File", RB_IO_PATH(fptr)); |
226 | | | 214 | |
227 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 215 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
228 | @@ -272,5 +288,5 @@ img_from_xbm(klass, f) | | 216 | @@ -272,5 +275,5 @@ img_from_xbm(klass, f) |
229 | VALUE klass, f; | | 217 | VALUE klass, f; |
230 | { | | 218 | { |
231 | - OpenFile *fptr; | | 219 | - OpenFile *fptr; |
232 | + rb_io_t *fptr; | | 220 | + rb_io_t *fptr; |
233 | gdImagePtr iptr; | | 221 | gdImagePtr iptr; |
234 | | | 222 | |
235 | @@ -280,7 +296,7 @@ img_from_xbm(klass, f) | | 223 | @@ -280,7 +283,7 @@ img_from_xbm(klass, f) |
236 | rb_io_check_readable(fptr); | | 224 | rb_io_check_readable(fptr); |
237 | | | 225 | |
238 | - iptr = gdImageCreateFromXbm(fptr->f); | | 226 | - iptr = gdImageCreateFromXbm(fptr->f); |
239 | + iptr = gdImageCreateFromXbm(rb_io_stdio_file(fptr)); | | 227 | + iptr = gdImageCreateFromXbm(rb_io_stdio_file(fptr)); |
240 | if (!iptr) | | 228 | if (!iptr) |
241 | - rb_raise(rb_eArgError, "%s is not a valid Xbm File", fptr->path); | | 229 | - rb_raise(rb_eArgError, "%s is not a valid Xbm File", fptr->path); |
242 | + rb_raise(rb_eArgError, "%s is not a valid Xbm File", RB_IO_PATH(fptr)); | | 230 | + rb_raise(rb_eArgError, "%s is not a valid Xbm File", RB_IO_PATH(fptr)); |
243 | | | 231 | |
244 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 232 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
245 | @@ -292,17 +308,17 @@ img_from_xbmfname(klass, fname) | | 233 | @@ -292,17 +295,17 @@ img_from_xbmfname(klass, fname) |
246 | { | | 234 | { |
247 | VALUE f; | | 235 | VALUE f; |
248 | - OpenFile *fptr; | | 236 | - OpenFile *fptr; |
249 | + rb_io_t *fptr; | | 237 | + rb_io_t *fptr; |
250 | gdImagePtr iptr; | | 238 | gdImagePtr iptr; |
251 | | | 239 | |
252 | Check_Type(fname, T_STRING); | | 240 | Check_Type(fname, T_STRING); |
253 | | | 241 | |
254 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 242 | - f = rb_file_open(STR2CSTR(fname), "r"); |
255 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 243 | + f = rb_file_open(StringValuePtr(fname), "r"); |
256 | rb_io_binmode(f); | | 244 | rb_io_binmode(f); |
257 | GetOpenFile(f, fptr); | | 245 | GetOpenFile(f, fptr); |
258 | rb_io_check_readable(fptr); | | 246 | rb_io_check_readable(fptr); |
259 | | | 247 | |
260 | - iptr = gdImageCreateFromXbm(fptr->f); | | 248 | - iptr = gdImageCreateFromXbm(fptr->f); |
261 | + iptr = gdImageCreateFromXbm(rb_io_stdio_file(fptr)); | | 249 | + iptr = gdImageCreateFromXbm(rb_io_stdio_file(fptr)); |
262 | if (!iptr) | | 250 | if (!iptr) |
263 | - rb_raise(rb_eArgError, "%s is not a valid Xbm File", fptr->path); | | 251 | - rb_raise(rb_eArgError, "%s is not a valid Xbm File", fptr->path); |
264 | + rb_raise(rb_eArgError, "%s is not a valid Xbm File", RB_IO_PATH(fptr)); | | 252 | + rb_raise(rb_eArgError, "%s is not a valid Xbm File", RB_IO_PATH(fptr)); |
265 | | | 253 | |
266 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 254 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
267 | @@ -314,5 +330,5 @@ img_from_xpm(klass, f) | | 255 | @@ -314,5 +317,5 @@ img_from_xpm(klass, f) |
268 | VALUE klass, f; | | 256 | VALUE klass, f; |
269 | { | | 257 | { |
270 | - OpenFile *fptr; | | 258 | - OpenFile *fptr; |
271 | + rb_io_t *fptr; | | 259 | + rb_io_t *fptr; |
272 | gdImagePtr iptr; | | 260 | gdImagePtr iptr; |
273 | | | 261 | |
274 | @@ -323,7 +339,7 @@ img_from_xpm(klass, f) | | 262 | @@ -323,7 +326,7 @@ img_from_xpm(klass, f) |
275 | | | 263 | |
276 | /* need cast, and the argument is char* type */ | | 264 | /* need cast, and the argument is char* type */ |
277 | - iptr = (gdImagePtr)gdImageCreateFromXpm(fptr->path); | | 265 | - iptr = (gdImagePtr)gdImageCreateFromXpm(fptr->path); |
278 | + iptr = (gdImagePtr)gdImageCreateFromXpm(RB_IO_PATH(fptr)); | | 266 | + iptr = (gdImagePtr)gdImageCreateFromXpm(RB_IO_PATH(fptr)); |
279 | if (!iptr) | | 267 | if (!iptr) |
280 | - rb_raise(rb_eArgError, "%s is not a valid XPM File", fptr->path); | | 268 | - rb_raise(rb_eArgError, "%s is not a valid XPM File", fptr->path); |
281 | + rb_raise(rb_eArgError, "%s is not a valid XPM File", RB_IO_PATH(fptr)); | | 269 | + rb_raise(rb_eArgError, "%s is not a valid XPM File", RB_IO_PATH(fptr)); |
282 | | | 270 | |
283 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 271 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
284 | @@ -335,10 +351,10 @@ img_from_xpmfname(klass, fname) | | 272 | @@ -335,10 +338,10 @@ img_from_xpmfname(klass, fname) |
285 | { | | 273 | { |
286 | VALUE f; | | 274 | VALUE f; |
287 | - OpenFile *fptr; | | 275 | - OpenFile *fptr; |
288 | + rb_io_t *fptr; | | 276 | + rb_io_t *fptr; |
289 | gdImagePtr iptr; | | 277 | gdImagePtr iptr; |
290 | | | 278 | |
291 | Check_Type(fname, T_STRING); | | 279 | Check_Type(fname, T_STRING); |
292 | | | 280 | |
293 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 281 | - f = rb_file_open(STR2CSTR(fname), "r"); |
294 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 282 | + f = rb_file_open(StringValuePtr(fname), "r"); |
295 | rb_io_binmode(f); | | 283 | rb_io_binmode(f); |
296 | GetOpenFile(f, fptr); | | 284 | GetOpenFile(f, fptr); |
297 | @@ -346,7 +362,7 @@ img_from_xpmfname(klass, fname) | | 285 | @@ -346,7 +349,7 @@ img_from_xpmfname(klass, fname) |
298 | | | 286 | |
299 | /* need cast, and the argument is char* type */ | | 287 | /* need cast, and the argument is char* type */ |
300 | - iptr = (gdImagePtr)gdImageCreateFromXpm(fptr->path); | | 288 | - iptr = (gdImagePtr)gdImageCreateFromXpm(fptr->path); |
301 | + iptr = (gdImagePtr)gdImageCreateFromXpm(RB_IO_PATH(fptr)); | | 289 | + iptr = (gdImagePtr)gdImageCreateFromXpm(RB_IO_PATH(fptr)); |
302 | if (!iptr) | | 290 | if (!iptr) |
303 | - rb_raise(rb_eArgError, "%s is not a valid XPM File", fptr->path); | | 291 | - rb_raise(rb_eArgError, "%s is not a valid XPM File", fptr->path); |
304 | + rb_raise(rb_eArgError, "%s is not a valid XPM File", RB_IO_PATH(fptr)); | | 292 | + rb_raise(rb_eArgError, "%s is not a valid XPM File", RB_IO_PATH(fptr)); |
305 | | | 293 | |
306 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 294 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
307 | @@ -360,5 +376,5 @@ img_from_jpeg(klass, f) | | 295 | @@ -360,5 +363,5 @@ img_from_jpeg(klass, f) |
308 | VALUE klass, f; | | 296 | VALUE klass, f; |
309 | { | | 297 | { |
310 | - OpenFile *fptr; | | 298 | - OpenFile *fptr; |
311 | + rb_io_t *fptr; | | 299 | + rb_io_t *fptr; |
312 | gdImagePtr iptr; | | 300 | gdImagePtr iptr; |
313 | | | 301 | |
314 | @@ -368,7 +384,7 @@ img_from_jpeg(klass, f) | | 302 | @@ -368,7 +371,7 @@ img_from_jpeg(klass, f) |
315 | rb_io_check_readable(fptr); | | 303 | rb_io_check_readable(fptr); |
316 | | | 304 | |
317 | - iptr = gdImageCreateFromJpeg(fptr->f); | | 305 | - iptr = gdImageCreateFromJpeg(fptr->f); |
318 | + iptr = gdImageCreateFromJpeg(rb_io_stdio_file(fptr)); | | 306 | + iptr = gdImageCreateFromJpeg(rb_io_stdio_file(fptr)); |
319 | if (!iptr) | | 307 | if (!iptr) |
320 | - rb_raise(rb_eArgError, "%s is not a valid Jpeg File", fptr->path); | | 308 | - rb_raise(rb_eArgError, "%s is not a valid Jpeg File", fptr->path); |
321 | + rb_raise(rb_eArgError, "%s is not a valid Jpeg File", RB_IO_PATH(fptr)); | | 309 | + rb_raise(rb_eArgError, "%s is not a valid Jpeg File", RB_IO_PATH(fptr)); |
322 | | | 310 | |
323 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 311 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
324 | @@ -380,17 +396,17 @@ img_from_jpegfname(klass, fname) | | 312 | @@ -380,17 +383,17 @@ img_from_jpegfname(klass, fname) |
325 | { | | 313 | { |
326 | VALUE f; | | 314 | VALUE f; |
327 | - OpenFile *fptr; | | 315 | - OpenFile *fptr; |
328 | + rb_io_t *fptr; | | 316 | + rb_io_t *fptr; |
329 | gdImagePtr iptr; | | 317 | gdImagePtr iptr; |
330 | | | 318 | |
331 | Check_Type(fname, T_STRING); | | 319 | Check_Type(fname, T_STRING); |
332 | | | 320 | |
333 | - f = rb_file_open(STR2CSTR(fname), "r"); | | 321 | - f = rb_file_open(STR2CSTR(fname), "r"); |
334 | + f = rb_file_open(StringValuePtr(fname), "r"); | | 322 | + f = rb_file_open(StringValuePtr(fname), "r"); |
335 | rb_io_binmode(f); | | 323 | rb_io_binmode(f); |
336 | GetOpenFile(f, fptr); | | 324 | GetOpenFile(f, fptr); |
337 | rb_io_check_readable(fptr); | | 325 | rb_io_check_readable(fptr); |
338 | | | 326 | |
339 | - iptr = gdImageCreateFromJpeg(fptr->f); | | 327 | - iptr = gdImageCreateFromJpeg(fptr->f); |
340 | + iptr = gdImageCreateFromJpeg(rb_io_stdio_file(fptr)); | | 328 | + iptr = gdImageCreateFromJpeg(rb_io_stdio_file(fptr)); |
341 | if (!iptr) | | 329 | if (!iptr) |
342 | - rb_raise(rb_eArgError, "%s is not a valid Jpeg File", fptr->path); | | 330 | - rb_raise(rb_eArgError, "%s is not a valid Jpeg File", fptr->path); |
343 | + rb_raise(rb_eArgError, "%s is not a valid Jpeg File", RB_IO_PATH(fptr)); | | 331 | + rb_raise(rb_eArgError, "%s is not a valid Jpeg File", RB_IO_PATH(fptr)); |
344 | | | 332 | |
345 | return Data_Wrap_Struct(klass,0,free_img,iptr); | | 333 | return Data_Wrap_Struct(klass,0,free_img,iptr); |
346 | @@ -419,10 +435,10 @@ hex2triplet(hex) | | 334 | @@ -419,10 +422,10 @@ hex2triplet(hex) |
347 | Check_Type(hex, T_STRING); | | 335 | Check_Type(hex, T_STRING); |
348 | | | 336 | |
349 | - if (RSTRING(hex)->len != 7) | | 337 | - if (RSTRING(hex)->len != 7) |
350 | - rb_raise(rb_eArgError, "Invalid format: %s", RSTRING(hex)->ptr); | | 338 | - rb_raise(rb_eArgError, "Invalid format: %s", RSTRING(hex)->ptr); |
351 | + if (RSTRING_LEN(hex) != 7) | | 339 | + if (RSTRING_LEN(hex) != 7) |
352 | + rb_raise(rb_eArgError, "Invalid format: %s", RSTRING_PTR(hex)); | | 340 | + rb_raise(rb_eArgError, "Invalid format: %s", RSTRING_PTR(hex)); |
353 | | | 341 | |
354 | - rstr = rb_str_new(RSTRING(hex)->ptr + 1, 2); | | 342 | - rstr = rb_str_new(RSTRING(hex)->ptr + 1, 2); |
355 | - gstr = rb_str_new(RSTRING(hex)->ptr + 3, 2); | | 343 | - gstr = rb_str_new(RSTRING(hex)->ptr + 3, 2); |
356 | - bstr = rb_str_new(RSTRING(hex)->ptr + 5, 2); | | 344 | - bstr = rb_str_new(RSTRING(hex)->ptr + 5, 2); |
357 | + rstr = rb_str_new(RSTRING_PTR(hex) + 1, 2); | | 345 | + rstr = rb_str_new(RSTRING_PTR(hex) + 1, 2); |
358 | + gstr = rb_str_new(RSTRING_PTR(hex) + 3, 2); | | 346 | + gstr = rb_str_new(RSTRING_PTR(hex) + 3, 2); |
359 | + bstr = rb_str_new(RSTRING_PTR(hex) + 5, 2); | | 347 | + bstr = rb_str_new(RSTRING_PTR(hex) + 5, 2); |
360 | | | 348 | |
361 | ret_ary = rb_ary_new(); | | 349 | ret_ary = rb_ary_new(); |
362 | @@ -460,7 +476,7 @@ img_color_allocate_str(img, rgbstr) | | 350 | @@ -460,7 +463,7 @@ img_color_allocate_str(img, rgbstr) |
363 | ary = hex2triplet(rgbstr); | | 351 | ary = hex2triplet(rgbstr); |
364 | c = gdImageColorAllocate(im, | | 352 | c = gdImageColorAllocate(im, |
365 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 353 | - NUM2INT(*(RARRAY(ary)->ptr)), |
366 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 354 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
367 | - NUM2INT(*(RARRAY(ary)->ptr+2))); | | 355 | - NUM2INT(*(RARRAY(ary)->ptr+2))); |
368 | + NUM2INT(*(RARRAY_PTR(ary))), | | 356 | + NUM2INT(*(RARRAY_PTR(ary))), |
369 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 357 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
370 | + NUM2INT(*(RARRAY_PTR(ary)+2))); | | 358 | + NUM2INT(*(RARRAY_PTR(ary)+2))); |
371 | return INT2FIX(c); | | 359 | return INT2FIX(c); |
372 | } | | 360 | } |
373 | @@ -533,7 +549,7 @@ img_color_resolve_str(img, rgbstr) | | 361 | @@ -533,7 +536,7 @@ img_color_resolve_str(img, rgbstr) |
374 | ary = hex2triplet(rgbstr); | | 362 | ary = hex2triplet(rgbstr); |
375 | c = gdImageColorResolve(im, | | 363 | c = gdImageColorResolve(im, |
376 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 364 | - NUM2INT(*(RARRAY(ary)->ptr)), |
377 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 365 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
378 | - NUM2INT(*(RARRAY(ary)->ptr+2))); | | 366 | - NUM2INT(*(RARRAY(ary)->ptr+2))); |
379 | + NUM2INT(*(RARRAY_PTR(ary))), | | 367 | + NUM2INT(*(RARRAY_PTR(ary))), |
380 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 368 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
381 | + NUM2INT(*(RARRAY_PTR(ary)+2))); | | 369 | + NUM2INT(*(RARRAY_PTR(ary)+2))); |
382 | | | 370 | |
383 | return INT2FIX(c); | | 371 | return INT2FIX(c); |
384 | @@ -596,7 +612,7 @@ img_color_closest_str(img, rgbstr) | | 372 | @@ -596,7 +599,7 @@ img_color_closest_str(img, rgbstr) |
385 | ary = hex2triplet(rgbstr); | | 373 | ary = hex2triplet(rgbstr); |
386 | c = gdImageColorClosest(im, | | 374 | c = gdImageColorClosest(im, |
387 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 375 | - NUM2INT(*(RARRAY(ary)->ptr)), |
388 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 376 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
389 | - NUM2INT(*(RARRAY(ary)->ptr+2))); | | 377 | - NUM2INT(*(RARRAY(ary)->ptr+2))); |
390 | + NUM2INT(*(RARRAY_PTR(ary))), | | 378 | + NUM2INT(*(RARRAY_PTR(ary))), |
391 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 379 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
392 | + NUM2INT(*(RARRAY_PTR(ary)+2))); | | 380 | + NUM2INT(*(RARRAY_PTR(ary)+2))); |
393 | return INT2FIX(c); | | 381 | return INT2FIX(c); |
394 | } | | 382 | } |
395 | @@ -658,7 +674,7 @@ img_color_closestHWB_str(img, rgbstr) | | 383 | @@ -658,7 +661,7 @@ img_color_closestHWB_str(img, rgbstr) |
396 | ary = hex2triplet(rgbstr); | | 384 | ary = hex2triplet(rgbstr); |
397 | c = gdImageColorClosestHWB(im, | | 385 | c = gdImageColorClosestHWB(im, |
398 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 386 | - NUM2INT(*(RARRAY(ary)->ptr)), |
399 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 387 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
400 | - NUM2INT(*(RARRAY(ary)->ptr+2))); | | 388 | - NUM2INT(*(RARRAY(ary)->ptr+2))); |
401 | + NUM2INT(*(RARRAY_PTR(ary))), | | 389 | + NUM2INT(*(RARRAY_PTR(ary))), |
402 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 390 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
403 | + NUM2INT(*(RARRAY_PTR(ary)+2))); | | 391 | + NUM2INT(*(RARRAY_PTR(ary)+2))); |
404 | return INT2FIX(c); | | 392 | return INT2FIX(c); |
405 | } | | 393 | } |
406 | @@ -718,7 +734,7 @@ img_color_exact_str(img, rgbstr) | | 394 | @@ -718,7 +721,7 @@ img_color_exact_str(img, rgbstr) |
407 | ary = hex2triplet(rgbstr); | | 395 | ary = hex2triplet(rgbstr); |
408 | c = gdImageColorExact(im, | | 396 | c = gdImageColorExact(im, |
409 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 397 | - NUM2INT(*(RARRAY(ary)->ptr)), |
410 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 398 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
411 | - NUM2INT(*(RARRAY(ary)->ptr+2))); | | 399 | - NUM2INT(*(RARRAY(ary)->ptr+2))); |
412 | + NUM2INT(*(RARRAY_PTR(ary))), | | 400 | + NUM2INT(*(RARRAY_PTR(ary))), |
413 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 401 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
414 | + NUM2INT(*(RARRAY_PTR(ary)+2))); | | 402 | + NUM2INT(*(RARRAY_PTR(ary)+2))); |
415 | return INT2FIX(c); | | 403 | return INT2FIX(c); |
416 | } | | 404 | } |
417 | @@ -1000,9 +1016,9 @@ img_polygon(img, ply, c) | | 405 | @@ -990,5 +993,5 @@ static VALUE |
| | | 406 | img_polygon(img, ply, c) |
| | | 407 | VALUE img; |
| | | 408 | - struct RArray *ply; |
| | | 409 | + VALUE ply; |
| | | 410 | VALUE c; |
| | | 411 | { |
| | | 412 | @@ -1000,9 +1003,9 @@ img_polygon(img, ply, c) |
418 | | | 413 | |
419 | poly_req(ply); | | 414 | poly_req(ply); |
420 | - len = ply->len/2; | | 415 | - len = ply->len/2; |
421 | + len = RARRAY_LEN(ply)/2; | | 416 | + len = RARRAY_LEN(ply)/2; |
422 | pnt = ALLOCA_N(gdPoint, len); | | 417 | pnt = ALLOCA_N(gdPoint, len); |
423 | for (i=0; i<len; i++) { | | 418 | for (i=0; i<len; i++) { |
424 | - pnt[i].x = NUM2INT(ply->ptr[i*2]); | | 419 | - pnt[i].x = NUM2INT(ply->ptr[i*2]); |
425 | - pnt[i].y = NUM2INT(ply->ptr[i*2+1]); | | 420 | - pnt[i].y = NUM2INT(ply->ptr[i*2+1]); |
426 | + pnt[i].x = NUM2INT(RARRAY_PTR(ply)[i*2]); | | 421 | + pnt[i].x = NUM2INT(RARRAY_PTR(ply)[i*2]); |
427 | + pnt[i].y = NUM2INT(RARRAY_PTR(ply)[i*2+1]); | | 422 | + pnt[i].y = NUM2INT(RARRAY_PTR(ply)[i*2+1]); |
428 | } | | 423 | } |
429 | | | 424 | |
430 | @@ -1025,9 +1041,9 @@ img_filled_polygon(img, ply, c) | | 425 | @@ -1015,5 +1018,5 @@ static VALUE |
| | | 426 | img_filled_polygon(img, ply, c) |
| | | 427 | VALUE img; |
| | | 428 | - struct RArray *ply; |
| | | 429 | + VALUE ply; |
| | | 430 | VALUE c; |
| | | 431 | { |
| | | 432 | @@ -1025,9 +1028,9 @@ img_filled_polygon(img, ply, c) |
431 | | | 433 | |
432 | poly_req(ply); | | 434 | poly_req(ply); |
433 | - len = ply->len/2; | | 435 | - len = ply->len/2; |
434 | + len = RARRAY_LEN(ply)/2; | | 436 | + len = RARRAY_LEN(ply)/2; |
435 | pnt = ALLOCA_N(gdPoint, len); | | 437 | pnt = ALLOCA_N(gdPoint, len); |
436 | for (i=0; i<len; i++) { | | 438 | for (i=0; i<len; i++) { |
437 | - pnt[i].x = NUM2INT(ply->ptr[i*2]); | | 439 | - pnt[i].x = NUM2INT(ply->ptr[i*2]); |
438 | - pnt[i].y = NUM2INT(ply->ptr[i*2+1]); | | 440 | - pnt[i].y = NUM2INT(ply->ptr[i*2+1]); |
439 | + pnt[i].x = NUM2INT(RARRAY_PTR(ply)[i*2]); | | 441 | + pnt[i].x = NUM2INT(RARRAY_PTR(ply)[i*2]); |
440 | + pnt[i].y = NUM2INT(RARRAY_PTR(ply)[i*2+1]); | | 442 | + pnt[i].y = NUM2INT(RARRAY_PTR(ply)[i*2+1]); |
441 | } | | 443 | } |
442 | | | 444 | |
443 | @@ -1200,5 +1216,5 @@ img_string(img, fnt, x, y, str, c) | | 445 | @@ -1200,5 +1203,5 @@ img_string(img, fnt, x, y, str, c) |
444 | Data_Get_Struct(fnt, gdFont, f); | | 446 | Data_Get_Struct(fnt, gdFont, f); |
445 | | | 447 | |
446 | - gdImageString(im,f,NUM2INT(x),NUM2INT(y),RSTRING(str)->ptr,NUM2INT(c)); | | 448 | - gdImageString(im,f,NUM2INT(x),NUM2INT(y),RSTRING(str)->ptr,NUM2INT(c)); |
447 | + gdImageString(im,f,NUM2INT(x),NUM2INT(y),RSTRING_PTR(str),NUM2INT(c)); | | 449 | + gdImageString(im,f,NUM2INT(x),NUM2INT(y),RSTRING_PTR(str),NUM2INT(c)); |
448 | | | 450 | |
449 | return img; | | 451 | return img; |
450 | @@ -1217,5 +1233,5 @@ img_string_up(img, fnt, x, y, str, c) | | 452 | @@ -1217,5 +1220,5 @@ img_string_up(img, fnt, x, y, str, c) |
451 | Data_Get_Struct(fnt, gdFont, f); | | 453 | Data_Get_Struct(fnt, gdFont, f); |
452 | | | 454 | |
453 | - gdImageStringUp(im,f,NUM2INT(x),NUM2INT(y),RSTRING(str)->ptr,NUM2INT(c)); | | 455 | - gdImageStringUp(im,f,NUM2INT(x),NUM2INT(y),RSTRING(str)->ptr,NUM2INT(c)); |
454 | + gdImageStringUp(im,f,NUM2INT(x),NUM2INT(y),RSTRING_PTR(str),NUM2INT(c)); | | 456 | + gdImageStringUp(im,f,NUM2INT(x),NUM2INT(y),RSTRING_PTR(str),NUM2INT(c)); |
455 | | | 457 | |
456 | return img; | | 458 | return img; |
457 | @@ -1238,10 +1254,10 @@ img_s_string_ttf(klass, fgcolor, fontnam | | 459 | @@ -1238,10 +1241,10 @@ img_s_string_ttf(klass, fgcolor, fontnam |
458 | &brect[0], | | 460 | &brect[0], |
459 | NUM2INT(fgcolor), | | 461 | NUM2INT(fgcolor), |
460 | - RSTRING(fontname)->ptr, | | 462 | - RSTRING(fontname)->ptr, |
461 | + RSTRING_PTR(fontname), | | 463 | + RSTRING_PTR(fontname), |
462 | NUM2DBL(ptsize), | | 464 | NUM2DBL(ptsize), |
463 | NUM2DBL(angle), | | 465 | NUM2DBL(angle), |
464 | NUM2INT(x), | | 466 | NUM2INT(x), |
465 | NUM2INT(y), | | 467 | NUM2INT(y), |
466 | - RSTRING(string)->ptr); | | 468 | - RSTRING(string)->ptr); |
467 | + RSTRING_PTR(string)); | | 469 | + RSTRING_PTR(string)); |
468 | for (i=0; i<8; i++) { | | 470 | for (i=0; i<8; i++) { |
469 | rb_ary_push(ary, INT2FIX(brect[i])); | | 471 | rb_ary_push(ary, INT2FIX(brect[i])); |
470 | @@ -1270,10 +1286,10 @@ img_string_ttf(img, fgcolor, fontname, p | | 472 | @@ -1270,10 +1273,10 @@ img_string_ttf(img, fgcolor, fontname, p |
471 | &brect[0], | | 473 | &brect[0], |
472 | NUM2INT(fgcolor), | | 474 | NUM2INT(fgcolor), |
473 | - RSTRING(fontname)->ptr, | | 475 | - RSTRING(fontname)->ptr, |
474 | + RSTRING_PTR(fontname), | | 476 | + RSTRING_PTR(fontname), |
475 | NUM2DBL(ptsize), | | 477 | NUM2DBL(ptsize), |
476 | NUM2DBL(angle), | | 478 | NUM2DBL(angle), |
477 | NUM2INT(x), | | 479 | NUM2INT(x), |
478 | NUM2INT(y), | | 480 | NUM2INT(y), |
479 | - RSTRING(string)->ptr); | | 481 | - RSTRING(string)->ptr); |
480 | + RSTRING_PTR(string)); | | 482 | + RSTRING_PTR(string)); |
481 | for (i=0; i<8; i++) { | | 483 | for (i=0; i<8; i++) { |
482 | rb_ary_push(ary, INT2FIX(brect[i])); | | 484 | rb_ary_push(ary, INT2FIX(brect[i])); |
483 | @@ -1302,10 +1318,10 @@ img_s_string_ft(klass, fgcolor, fontname | | 485 | @@ -1302,10 +1305,10 @@ img_s_string_ft(klass, fgcolor, fontname |
484 | &brect[0], | | 486 | &brect[0], |
485 | NUM2INT(fgcolor), | | 487 | NUM2INT(fgcolor), |
486 | - RSTRING(fontname)->ptr, | | 488 | - RSTRING(fontname)->ptr, |
487 | + RSTRING_PTR(fontname), | | 489 | + RSTRING_PTR(fontname), |
488 | NUM2DBL(ptsize), | | 490 | NUM2DBL(ptsize), |
489 | NUM2DBL(angle), | | 491 | NUM2DBL(angle), |
490 | NUM2INT(x), | | 492 | NUM2INT(x), |
491 | NUM2INT(y), | | 493 | NUM2INT(y), |
492 | - RSTRING(string)->ptr); | | 494 | - RSTRING(string)->ptr); |
493 | + RSTRING_PTR(string)); | | 495 | + RSTRING_PTR(string)); |
494 | for (i=0; i<8; i++) { | | 496 | for (i=0; i<8; i++) { |
495 | rb_ary_push(ary, INT2FIX(brect[i])); | | 497 | rb_ary_push(ary, INT2FIX(brect[i])); |
496 | @@ -1334,10 +1350,10 @@ img_string_ft(img, fgcolor, fontname, pt | | 498 | @@ -1334,10 +1337,10 @@ img_string_ft(img, fgcolor, fontname, pt |
497 | &brect[0], | | 499 | &brect[0], |
498 | NUM2INT(fgcolor), | | 500 | NUM2INT(fgcolor), |
499 | - RSTRING(fontname)->ptr, | | 501 | - RSTRING(fontname)->ptr, |
500 | + RSTRING_PTR(fontname), | | 502 | + RSTRING_PTR(fontname), |
501 | NUM2DBL(ptsize), | | 503 | NUM2DBL(ptsize), |
502 | NUM2DBL(angle), | | 504 | NUM2DBL(angle), |
503 | NUM2INT(x), | | 505 | NUM2INT(x), |
504 | NUM2INT(y), | | 506 | NUM2INT(y), |
505 | - RSTRING(string)->ptr); | | 507 | - RSTRING(string)->ptr); |
506 | + RSTRING_PTR(string)); | | 508 | + RSTRING_PTR(string)); |
507 | for (i=0; i<8; i++) { | | 509 | for (i=0; i<8; i++) { |
508 | rb_ary_push(ary, INT2FIX(brect[i])); | | 510 | rb_ary_push(ary, INT2FIX(brect[i])); |
509 | @@ -1364,8 +1380,8 @@ img_char(img, fnt, x, y, ch, c) | | 511 | @@ -1364,8 +1367,8 @@ img_char(img, fnt, x, y, ch, c) |
510 | | | 512 | |
511 | if (TYPE(ch) == T_STRING) { | | 513 | if (TYPE(ch) == T_STRING) { |
512 | - if (RSTRING(ch)->len != 1) { | | 514 | - if (RSTRING(ch)->len != 1) { |
513 | - rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING(ch)->len); | | 515 | - rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING(ch)->len); |
514 | + if (RSTRING_LEN(ch) != 1) { | | 516 | + if (RSTRING_LEN(ch) != 1) { |
515 | + rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING_LEN(ch)); | | 517 | + rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING_LEN(ch)); |
516 | } | | 518 | } |
517 | - ci = RSTRING(ch)->ptr[0]; | | 519 | - ci = RSTRING(ch)->ptr[0]; |
518 | + ci = RSTRING_PTR(ch)[0]; | | 520 | + ci = RSTRING_PTR(ch)[0]; |
519 | } | | 521 | } |
520 | else { | | 522 | else { |
521 | @@ -1390,8 +1406,8 @@ img_char_up(img, fnt, x, y, ch, c) | | 523 | @@ -1390,8 +1393,8 @@ img_char_up(img, fnt, x, y, ch, c) |
522 | | | 524 | |
523 | if (TYPE(ch) == T_STRING) { | | 525 | if (TYPE(ch) == T_STRING) { |
524 | - if (RSTRING(ch)->len != 1) { | | 526 | - if (RSTRING(ch)->len != 1) { |
525 | - rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING(ch)->len); | | 527 | - rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING(ch)->len); |
526 | + if (RSTRING_LEN(ch) != 1) { | | 528 | + if (RSTRING_LEN(ch) != 1) { |
527 | + rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING_LEN(ch)); | | 529 | + rb_raise(rb_eArgError, "string must be 1 byte(%d bytes)", RSTRING_LEN(ch)); |
528 | } | | 530 | } |
529 | - ci = RSTRING(ch)->ptr[0]; | | 531 | - ci = RSTRING(ch)->ptr[0]; |
530 | + ci = RSTRING_PTR(ch)[0]; | | 532 | + ci = RSTRING_PTR(ch)[0]; |
531 | } | | 533 | } |
532 | else { | | 534 | else { |
533 | @@ -1418,4 +1434,6 @@ img_get_interlace(img) | | 535 | @@ -1418,4 +1421,6 @@ img_get_interlace(img) |
534 | static VALUE | | 536 | static VALUE |
535 | img_set_interlace(img, val) | | 537 | img_set_interlace(img, val) |
536 | + VALUE img; | | 538 | + VALUE img; |
537 | + VALUE val; | | 539 | + VALUE val; |
538 | { | | 540 | { |
539 | gdImagePtr im; | | 541 | gdImagePtr im; |
540 | @@ -1499,5 +1517,5 @@ img_png(img, out) | | 542 | @@ -1499,5 +1504,5 @@ img_png(img, out) |
541 | { | | 543 | { |
542 | gdImagePtr im; | | 544 | gdImagePtr im; |
543 | - OpenFile *fptr; | | 545 | - OpenFile *fptr; |
544 | + rb_io_t *fptr; | | 546 | + rb_io_t *fptr; |
545 | FILE *f; | | 547 | FILE *f; |
546 | | | 548 | |
547 | @@ -1507,5 +1525,5 @@ img_png(img, out) | | 549 | @@ -1507,5 +1512,5 @@ img_png(img, out) |
548 | GetOpenFile(out, fptr); | | 550 | GetOpenFile(out, fptr); |
549 | rb_io_check_writable(fptr); | | 551 | rb_io_check_writable(fptr); |
550 | - f = (fptr->f2) ? fptr->f2 : fptr->f; | | 552 | - f = (fptr->f2) ? fptr->f2 : fptr->f; |
551 | + f = RB_IO_FILE(fptr); | | 553 | + f = RB_IO_FILE(fptr); |
552 | | | 554 | |
553 | gdImagePng(im, f); | | 555 | gdImagePng(im, f); |
554 | @@ -1543,5 +1561,5 @@ img_gif(img, out) | | 556 | @@ -1543,5 +1548,5 @@ img_gif(img, out) |
555 | { | | 557 | { |
556 | gdImagePtr im; | | 558 | gdImagePtr im; |
557 | - OpenFile *fptr; | | 559 | - OpenFile *fptr; |
558 | + rb_io_t *fptr; | | 560 | + rb_io_t *fptr; |
559 | FILE *f; | | 561 | FILE *f; |
560 | | | 562 | |
561 | @@ -1551,5 +1569,5 @@ img_gif(img, out) | | 563 | @@ -1551,5 +1556,5 @@ img_gif(img, out) |
562 | GetOpenFile(out, fptr); | | 564 | GetOpenFile(out, fptr); |
563 | rb_io_check_writable(fptr); | | 565 | rb_io_check_writable(fptr); |
564 | - f = (fptr->f2) ? fptr->f2 : fptr->f; | | 566 | - f = (fptr->f2) ? fptr->f2 : fptr->f; |
565 | + f = RB_IO_FILE(fptr); | | 567 | + f = RB_IO_FILE(fptr); |
566 | | | 568 | |
567 | gdImageGif(im, f); | | 569 | gdImageGif(im, f); |
568 | @@ -1582,5 +1600,5 @@ img_gd(img, out) | | 570 | @@ -1582,5 +1587,5 @@ img_gd(img, out) |
569 | { | | 571 | { |
570 | gdImagePtr im; | | 572 | gdImagePtr im; |
571 | - OpenFile *fptr; | | 573 | - OpenFile *fptr; |
572 | + rb_io_t *fptr; | | 574 | + rb_io_t *fptr; |
573 | FILE *f; | | 575 | FILE *f; |
574 | | | 576 | |
575 | @@ -1590,5 +1608,5 @@ img_gd(img, out) | | 577 | @@ -1590,5 +1595,5 @@ img_gd(img, out) |
576 | GetOpenFile(out, fptr); | | 578 | GetOpenFile(out, fptr); |
577 | rb_io_check_writable(fptr); | | 579 | rb_io_check_writable(fptr); |
578 | - f = (fptr->f2) ? fptr->f2 : fptr->f; | | 580 | - f = (fptr->f2) ? fptr->f2 : fptr->f; |
579 | + f = RB_IO_FILE(fptr); | | 581 | + f = RB_IO_FILE(fptr); |
580 | | | 582 | |
581 | gdImageGd(im, f); | | 583 | gdImageGd(im, f); |
582 | @@ -1601,5 +1619,5 @@ img_gd2(img, out, cs, fmt) | | 584 | @@ -1601,5 +1606,5 @@ img_gd2(img, out, cs, fmt) |
583 | VALUE img, out, cs, fmt; | | 585 | VALUE img, out, cs, fmt; |
584 | { | | 586 | { |
585 | - OpenFile *fptr; | | 587 | - OpenFile *fptr; |
586 | + rb_io_t *fptr; | | 588 | + rb_io_t *fptr; |
587 | gdImagePtr im; | | 589 | gdImagePtr im; |
588 | FILE *f; | | 590 | FILE *f; |
589 | @@ -1609,5 +1627,5 @@ img_gd2(img, out, cs, fmt) | | 591 | @@ -1609,5 +1614,5 @@ img_gd2(img, out, cs, fmt) |
590 | GetOpenFile(out, fptr); | | 592 | GetOpenFile(out, fptr); |
591 | rb_io_check_writable(fptr); | | 593 | rb_io_check_writable(fptr); |
592 | - f = (fptr->f2) ? fptr->f2 : fptr->f; | | 594 | - f = (fptr->f2) ? fptr->f2 : fptr->f; |
593 | + f = RB_IO_FILE(fptr); | | 595 | + f = RB_IO_FILE(fptr); |
594 | | | 596 | |
595 | Data_Get_Struct(img, gdImage, im); | | 597 | Data_Get_Struct(img, gdImage, im); |
596 | @@ -1624,5 +1642,5 @@ img_jpeg(img, out, quality) | | 598 | @@ -1624,5 +1629,5 @@ img_jpeg(img, out, quality) |
597 | { | | 599 | { |
598 | gdImagePtr im; | | 600 | gdImagePtr im; |
599 | - OpenFile *fptr; | | 601 | - OpenFile *fptr; |
600 | + rb_io_t *fptr; | | 602 | + rb_io_t *fptr; |
601 | FILE *f; | | 603 | FILE *f; |
602 | | | 604 | |
603 | @@ -1634,5 +1652,5 @@ img_jpeg(img, out, quality) | | 605 | @@ -1634,5 +1639,5 @@ img_jpeg(img, out, quality) |
604 | GetOpenFile(out, fptr); | | 606 | GetOpenFile(out, fptr); |
605 | rb_io_check_writable(fptr); | | 607 | rb_io_check_writable(fptr); |
606 | - f = (fptr->f2) ? fptr->f2 : fptr->f; | | 608 | - f = (fptr->f2) ? fptr->f2 : fptr->f; |
607 | + f = RB_IO_FILE(fptr); | | 609 | + f = RB_IO_FILE(fptr); |
608 | | | 610 | |
609 | gdImageJpeg(im, f, FIX2INT(quality)); | | 611 | gdImageJpeg(im, f, FIX2INT(quality)); |
610 | @@ -1669,5 +1687,5 @@ img_wbmp(img, fg, out) | | 612 | @@ -1669,5 +1674,5 @@ img_wbmp(img, fg, out) |
611 | { | | 613 | { |
612 | gdImagePtr im; | | 614 | gdImagePtr im; |
613 | - OpenFile *fptr; | | 615 | - OpenFile *fptr; |
614 | + rb_io_t *fptr; | | 616 | + rb_io_t *fptr; |
615 | FILE *f; | | 617 | FILE *f; |
616 | | | 618 | |
617 | @@ -1679,5 +1697,5 @@ img_wbmp(img, fg, out) | | 619 | @@ -1679,5 +1684,5 @@ img_wbmp(img, fg, out) |
618 | GetOpenFile(out, fptr); | | 620 | GetOpenFile(out, fptr); |
619 | rb_io_check_writable(fptr); | | 621 | rb_io_check_writable(fptr); |
620 | - f = (fptr->f2) ? fptr->f2 : fptr->f; | | 622 | - f = (fptr->f2) ? fptr->f2 : fptr->f; |
621 | + f = RB_IO_FILE(fptr); | | 623 | + f = RB_IO_FILE(fptr); |
622 | | | 624 | |
623 | gdImageWBMP(im, FIX2INT(fg), f); | | 625 | gdImageWBMP(im, FIX2INT(fg), f); |
624 | @@ -1698,5 +1716,9 @@ ply_new(klass) | | 626 | @@ -1698,5 +1703,5 @@ ply_new(klass) |
625 | VALUE self = rb_ary_new(); | | 627 | VALUE self = rb_ary_new(); |
626 | | | 628 | |
627 | +#if RUBY_API_VERSION_MAJOR >=2 && RUBY_API_VERSION_MINOR >= 1 | | 629 | - RBASIC(self)->klass = klass; |
628 | + rb_obj_reveal(self, klass); | | 630 | + rb_obj_reveal(self, klass); |
629 | +#else | | | |
630 | RBASIC(self)->klass = klass; | | | |
631 | +#endif | | | |
632 | return self; | | 631 | return self; |
633 | } | | 632 | } |
634 | @@ -1725,7 +1747,7 @@ ply_to_pt(ply, dx, dy) | | 633 | @@ -1725,7 +1730,7 @@ ply_to_pt(ply, dx, dy) |
635 | NUM2INT(dy); | | 634 | NUM2INT(dy); |
636 | | | 635 | |
637 | - if (RARRAY(ply)->len > 0) { | | 636 | - if (RARRAY(ply)->len > 0) { |
638 | - x = rb_ary_entry(ply, RARRAY(ply)->len - 2); | | 637 | - x = rb_ary_entry(ply, RARRAY(ply)->len - 2); |
639 | - y = rb_ary_entry(ply, RARRAY(ply)->len - 1); | | 638 | - y = rb_ary_entry(ply, RARRAY(ply)->len - 1); |
640 | + if (RARRAY_LEN(ply) > 0) { | | 639 | + if (RARRAY_LEN(ply) > 0) { |
641 | + x = rb_ary_entry(ply, RARRAY_LEN(ply) - 2); | | 640 | + x = rb_ary_entry(ply, RARRAY_LEN(ply) - 2); |
642 | + y = rb_ary_entry(ply, RARRAY_LEN(ply) - 1); | | 641 | + y = rb_ary_entry(ply, RARRAY_LEN(ply) - 1); |
643 | rb_ary_push(ply, INT2NUM(NUM2INT(x) + NUM2INT(dx))); | | 642 | rb_ary_push(ply, INT2NUM(NUM2INT(x) + NUM2INT(dx))); |
644 | rb_ary_push(ply, INT2NUM(NUM2INT(y) + NUM2INT(dy))); | | 643 | rb_ary_push(ply, INT2NUM(NUM2INT(y) + NUM2INT(dy))); |
645 | @@ -1742,5 +1764,5 @@ ply_get_pt(ply, idx) | | 644 | @@ -1742,5 +1747,5 @@ ply_get_pt(ply, idx) |
646 | int i = NUM2INT(idx); | | 645 | int i = NUM2INT(idx); |
647 | | | 646 | |
648 | - if (RARRAY(ply)->len < idx) return Qnil; | | 647 | - if (RARRAY(ply)->len < idx) return Qnil; |
649 | + if (RARRAY_LEN(ply) < idx) return Qnil; | | 648 | + if (RARRAY_LEN(ply) < idx) return Qnil; |
650 | i *= 2; | | 649 | i *= 2; |
651 | | | 650 | |
652 | @@ -1780,5 +1802,5 @@ ply_length(ply) | | 651 | @@ -1780,16 +1785,16 @@ ply_length(ply) |
653 | VALUE ply; | | 652 | VALUE ply; |
654 | { | | 653 | { |
655 | - return INT2FIX(RARRAY(ply)->len / 2); | | 654 | - return INT2FIX(RARRAY(ply)->len / 2); |
656 | + return INT2FIX(RARRAY_LEN(ply) / 2); | | 655 | + return INT2FIX(RARRAY_LEN(ply) / 2); |
657 | } | | 656 | } |
658 | | | 657 | |
659 | @@ -1788,8 +1810,8 @@ ply_vertices(ply) | | 658 | static VALUE |
| | | 659 | ply_vertices(ply) |
| | | 660 | - struct RArray *ply; |
| | | 661 | + VALUE ply; |
660 | { | | 662 | { |
661 | int i; | | 663 | int i; |
662 | - VALUE ary = rb_ary_new2(ply->len/2); | | 664 | - VALUE ary = rb_ary_new2(ply->len/2); |
663 | + VALUE ary = rb_ary_new2(RARRAY_LEN(ply)/2); | | 665 | + VALUE ary = rb_ary_new2(RARRAY_LEN(ply)/2); |
664 | | | 666 | |
665 | - for (i = 0; i<ply->len; i+=2) { | | 667 | - for (i = 0; i<ply->len; i+=2) { |
666 | - rb_ary_push(ary, rb_assoc_new(ply->ptr[i], ply->ptr[i+1])); | | 668 | - rb_ary_push(ary, rb_assoc_new(ply->ptr[i], ply->ptr[i+1])); |
667 | + for (i = 0; i< RARRAY_LEN(ply); i+=2) { | | 669 | + for (i = 0; i< RARRAY_LEN(ply); i+=2) { |
668 | + rb_ary_push(ary, rb_assoc_new(RARRAY_PTR(ply)[i], RARRAY_PTR(ply)[i+1])); | | 670 | + rb_ary_push(ary, rb_assoc_new(RARRAY_PTR(ply)[i], RARRAY_PTR(ply)[i+1])); |
669 | } | | 671 | } |
670 | return ary; | | 672 | return ary; |
671 | @@ -1803,16 +1825,16 @@ ply_bounds(ply) | | 673 | @@ -1798,21 +1803,21 @@ ply_vertices(ply) |
| | | 674 | static VALUE |
| | | 675 | ply_bounds(ply) |
| | | 676 | - struct RArray *ply; |
| | | 677 | + VALUE ply; |
| | | 678 | { |
| | | 679 | int i, l, t, r, b; |
672 | int nx, ny; | | 680 | int nx, ny; |
673 | | | 681 | |
674 | - if (ply->len == 0) { | | 682 | - if (ply->len == 0) { |
675 | + if (RARRAY_LEN(ply) == 0) { | | 683 | + if (RARRAY_LEN(ply) == 0) { |
676 | l = t = r = b = 0; | | 684 | l = t = r = b = 0; |
677 | } | | 685 | } |
678 | else { | | 686 | else { |
679 | - l = r = NUM2INT(ply->ptr[0]); | | 687 | - l = r = NUM2INT(ply->ptr[0]); |
680 | - t = b = NUM2INT(ply->ptr[1]); | | 688 | - t = b = NUM2INT(ply->ptr[1]); |
681 | + l = r = NUM2INT(RARRAY_PTR(ply)[0]); | | 689 | + l = r = NUM2INT(RARRAY_PTR(ply)[0]); |
682 | + t = b = NUM2INT(RARRAY_PTR(ply)[1]); | | 690 | + t = b = NUM2INT(RARRAY_PTR(ply)[1]); |
683 | } | | 691 | } |
684 | - for (i = 2; i<ply->len; i+=2) { | | 692 | - for (i = 2; i<ply->len; i+=2) { |
685 | - nx = NUM2INT(ply->ptr[i]); | | 693 | - nx = NUM2INT(ply->ptr[i]); |
686 | + for (i = 2; i< RARRAY_LEN(ply); i+=2) { | | 694 | + for (i = 2; i< RARRAY_LEN(ply); i+=2) { |
687 | + nx = NUM2INT(RARRAY_PTR(ply)[i]); | | 695 | + nx = NUM2INT(RARRAY_PTR(ply)[i]); |
688 | if (nx < l) l = nx; | | 696 | if (nx < l) l = nx; |
689 | if (nx > r) r = nx; | | 697 | if (nx > r) r = nx; |
690 | - ny = NUM2INT(ply->ptr[i+1]); | | 698 | - ny = NUM2INT(ply->ptr[i+1]); |
691 | + ny = NUM2INT(RARRAY_PTR(ply)[i+1]); | | 699 | + ny = NUM2INT(RARRAY_PTR(ply)[i+1]); |
692 | if (ny < t) t = ny; | | 700 | if (ny < t) t = ny; |
693 | if (ny > b) b = ny; | | 701 | if (ny > b) b = ny; |
694 | @@ -1831,9 +1853,9 @@ ply_offset(ply, vx, vy) | | 702 | @@ -1823,5 +1828,5 @@ ply_bounds(ply) |
| | | 703 | static VALUE |
| | | 704 | ply_offset(ply, vx, vy) |
| | | 705 | - struct RArray *ply; |
| | | 706 | + VALUE ply; |
| | | 707 | VALUE vx, vy; |
| | | 708 | { |
| | | 709 | @@ -1831,9 +1836,9 @@ ply_offset(ply, vx, vy) |
695 | y = NUM2INT(vy); | | 710 | y = NUM2INT(vy); |
696 | | | 711 | |
697 | - for (i = 0; i<ply->len; i+=2) { | | 712 | - for (i = 0; i<ply->len; i+=2) { |
698 | - c = NUM2INT(ply->ptr[i]) + x; | | 713 | - c = NUM2INT(ply->ptr[i]) + x; |
699 | - ply->ptr[i] = INT2FIX(c); | | 714 | - ply->ptr[i] = INT2FIX(c); |
700 | - c = NUM2INT(ply->ptr[i+1]) + y; | | 715 | - c = NUM2INT(ply->ptr[i+1]) + y; |
701 | - ply->ptr[i+1] = INT2FIX(c); | | 716 | - ply->ptr[i+1] = INT2FIX(c); |
702 | + for (i = 0; i< RARRAY_LEN(ply); i+=2) { | | 717 | + for (i = 0; i< RARRAY_LEN(ply); i+=2) { |
703 | + c = NUM2INT(RARRAY_PTR(ply)[i]) + x; | | 718 | + c = NUM2INT(RARRAY_PTR(ply)[i]) + x; |
704 | + RARRAY_PTR(ply)[i] = INT2FIX(c); | | 719 | + RARRAY_PTR(ply)[i] = INT2FIX(c); |
705 | + c = NUM2INT(RARRAY_PTR(ply)[i+1]) + y; | | 720 | + c = NUM2INT(RARRAY_PTR(ply)[i+1]) + y; |
706 | + RARRAY_PTR(ply)[i+1] = INT2FIX(c); | | 721 | + RARRAY_PTR(ply)[i+1] = INT2FIX(c); |
707 | } | | 722 | } |
708 | | | 723 | |
709 | @@ -1858,16 +1880,16 @@ ply_map(argc, argv, ply) | | 724 | @@ -1845,5 +1850,5 @@ ply_map(argc, argv, ply) |
| | | 725 | int argc; |
| | | 726 | VALUE *argv; |
| | | 727 | - struct RArray *ply; |
| | | 728 | + VALUE ply; |
| | | 729 | { |
| | | 730 | VALUE sl, st, sr, sb, dl, dt, dr, db; |
| | | 731 | @@ -1858,16 +1863,16 @@ ply_map(argc, argv, ply) |
710 | int nx, ny; | | 732 | int nx, ny; |
711 | | | 733 | |
712 | - if (ply->len == 0) { | | 734 | - if (ply->len == 0) { |
713 | + if (RARRAY_LEN(ply) == 0) { | | 735 | + if (RARRAY_LEN(ply) == 0) { |
714 | l = t = r = b = 0; | | 736 | l = t = r = b = 0; |
715 | } | | 737 | } |
716 | else { | | 738 | else { |
717 | - l = r = NUM2INT(ply->ptr[0]); | | 739 | - l = r = NUM2INT(ply->ptr[0]); |
718 | - t = b = NUM2INT(ply->ptr[1]); | | 740 | - t = b = NUM2INT(ply->ptr[1]); |
719 | + l = r = NUM2INT(RARRAY_PTR(ply)[0]); | | 741 | + l = r = NUM2INT(RARRAY_PTR(ply)[0]); |
720 | + t = b = NUM2INT(RARRAY_PTR(ply)[1]); | | 742 | + t = b = NUM2INT(RARRAY_PTR(ply)[1]); |
721 | } | | 743 | } |
722 | - for (i = 2; i<ply->len; i+=2) { | | 744 | - for (i = 2; i<ply->len; i+=2) { |
723 | - nx = NUM2INT(ply->ptr[i]); | | 745 | - nx = NUM2INT(ply->ptr[i]); |
724 | + for (i = 2; i<RARRAY_LEN(ply); i+=2) { | | 746 | + for (i = 2; i<RARRAY_LEN(ply); i+=2) { |
725 | + nx = NUM2INT(RARRAY_PTR(ply)[i]); | | 747 | + nx = NUM2INT(RARRAY_PTR(ply)[i]); |
726 | if (nx < l) l = nx; | | 748 | if (nx < l) l = nx; |
727 | if (nx > r) r = nx; | | 749 | if (nx > r) r = nx; |
728 | - ny = NUM2INT(ply->ptr[i+1]); | | 750 | - ny = NUM2INT(ply->ptr[i+1]); |
729 | + ny = NUM2INT(RARRAY_PTR(ply)[i+1]); | | 751 | + ny = NUM2INT(RARRAY_PTR(ply)[i+1]); |
730 | if (ny < t) t = ny; | | 752 | if (ny < t) t = ny; |
731 | if (ny > b) b = ny; | | 753 | if (ny > b) b = ny; |
732 | @@ -1894,12 +1916,12 @@ ply_map(argc, argv, ply) | | 754 | @@ -1894,12 +1899,12 @@ ply_map(argc, argv, ply) |
733 | } | | 755 | } |
734 | | | 756 | |
735 | - for (i = 0; i<ply->len; i+=2) { | | 757 | - for (i = 0; i<ply->len; i+=2) { |
736 | - c = NUM2INT(ply->ptr[i]); | | 758 | - c = NUM2INT(ply->ptr[i]); |
737 | + for (i = 0; i<RARRAY_LEN(ply); i+=2) { | | 759 | + for (i = 0; i<RARRAY_LEN(ply); i+=2) { |
738 | + c = NUM2INT(RARRAY_PTR(ply)[i]); | | 760 | + c = NUM2INT(RARRAY_PTR(ply)[i]); |
739 | c = (c-sx)*xmag+dx; | | 761 | c = (c-sx)*xmag+dx; |
740 | - ply->ptr[i] = INT2FIX(c); | | 762 | - ply->ptr[i] = INT2FIX(c); |
741 | + RARRAY_PTR(ply)[i] = INT2FIX(c); | | 763 | + RARRAY_PTR(ply)[i] = INT2FIX(c); |
742 | | | 764 | |
743 | - c = NUM2INT(ply->ptr[i+1]); | | 765 | - c = NUM2INT(ply->ptr[i+1]); |
744 | + c = NUM2INT(RARRAY_PTR(ply)[i+1]); | | 766 | + c = NUM2INT(RARRAY_PTR(ply)[i+1]); |
745 | c = (c-sy)*ymag+dy; | | 767 | c = (c-sy)*ymag+dy; |
746 | - ply->ptr[i+1] = INT2FIX(c); | | 768 | - ply->ptr[i+1] = INT2FIX(c); |
747 | + RARRAY_PTR(ply)[i+1] = INT2FIX(c); | | 769 | + RARRAY_PTR(ply)[i+1] = INT2FIX(c); |
748 | } | | 770 | } |
749 | | | 771 | |
750 | @@ -1914,9 +1936,9 @@ ply_transform(ply, a, b, c, d, tx, ty) | | 772 | @@ -1914,9 +1919,9 @@ ply_transform(ply, a, b, c, d, tx, ty) |
751 | VALUE x, y; | | 773 | VALUE x, y; |
752 | | | 774 | |
753 | - for (i = 0; i < RARRAY(ply)->len / 2; i++) { | | 775 | - for (i = 0; i < RARRAY(ply)->len / 2; i++) { |
754 | + for (i = 0; i < RARRAY_LEN(ply) / 2; i++) { | | 776 | + for (i = 0; i < RARRAY_LEN(ply) / 2; i++) { |
755 | /* x = rb_ary_entry(ply, i * 2); | | 777 | /* x = rb_ary_entry(ply, i * 2); |
756 | y = rb_ary_entry(ply, i * 2 + 1);*/ | | 778 | y = rb_ary_entry(ply, i * 2 + 1);*/ |
757 | - x = RARRAY(ply)->ptr[i * 2]; | | 779 | - x = RARRAY(ply)->ptr[i * 2]; |
758 | - y = RARRAY(ply)->ptr[i * 2 + 1]; | | 780 | - y = RARRAY(ply)->ptr[i * 2 + 1]; |
759 | + x = RARRAY_PTR(ply)[i * 2]; | | 781 | + x = RARRAY_PTR(ply)[i * 2]; |
760 | + y = RARRAY_PTR(ply)[i * 2 + 1]; | | 782 | + y = RARRAY_PTR(ply)[i * 2 + 1]; |
761 | ply_set_pt(ply, INT2NUM(i), | | 783 | ply_set_pt(ply, INT2NUM(i), |
762 | INT2NUM(NUM2DBL(a) * NUM2INT(x) + NUM2DBL(c) * NUM2INT(y) + NUM2INT(tx)), | | 784 | INT2NUM(NUM2DBL(a) * NUM2INT(x) + NUM2DBL(c) * NUM2INT(y) + NUM2INT(tx)), |
763 | @@ -1968,5 +1990,5 @@ fnt_s_new(obj, name) | | 785 | @@ -1965,8 +1970,8 @@ static VALUE |
| | | 786 | fnt_s_new(obj, name) |
| | | 787 | VALUE obj; |
| | | 788 | - struct RString *name; |
| | | 789 | + VALUE name; |
764 | { | | 790 | { |
765 | Check_Type(name, T_STRING); | | 791 | Check_Type(name, T_STRING); |
766 | - return fnt_new(name->ptr); | | 792 | - return fnt_new(name->ptr); |
767 | + return fnt_new(RSTRING_PTR(name)); | | 793 | + return fnt_new(RSTRING_PTR(name)); |
768 | } | | 794 | } |
769 | | | 795 | |
770 | @@ -2060,7 +2082,7 @@ img_color_allocate_alpha_str(img, rgbstr | | 796 | @@ -2060,7 +2065,7 @@ img_color_allocate_alpha_str(img, rgbstr |
771 | ary = hex2triplet(rgbstr); | | 797 | ary = hex2triplet(rgbstr); |
772 | c = gdImageColorAllocateAlpha(im, | | 798 | c = gdImageColorAllocateAlpha(im, |
773 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 799 | - NUM2INT(*(RARRAY(ary)->ptr)), |
774 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 800 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
775 | - NUM2INT(*(RARRAY(ary)->ptr+2)), | | 801 | - NUM2INT(*(RARRAY(ary)->ptr+2)), |
776 | + NUM2INT(*(RARRAY_PTR(ary))), | | 802 | + NUM2INT(*(RARRAY_PTR(ary))), |
777 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 803 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
778 | + NUM2INT(*(RARRAY_PTR(ary)+2)), | | 804 | + NUM2INT(*(RARRAY_PTR(ary)+2)), |
779 | NUM2INT(a)); | | 805 | NUM2INT(a)); |
780 | return INT2NUM(c); | | 806 | return INT2NUM(c); |
781 | @@ -2122,7 +2144,7 @@ img_color_resolve_alpha_str(img, rgbstr, | | 807 | @@ -2122,7 +2127,7 @@ img_color_resolve_alpha_str(img, rgbstr, |
782 | ary = hex2triplet(rgbstr); | | 808 | ary = hex2triplet(rgbstr); |
783 | c = gdImageColorResolveAlpha(im, | | 809 | c = gdImageColorResolveAlpha(im, |
784 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 810 | - NUM2INT(*(RARRAY(ary)->ptr)), |
785 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 811 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
786 | - NUM2INT(*(RARRAY(ary)->ptr+2)), | | 812 | - NUM2INT(*(RARRAY(ary)->ptr+2)), |
787 | + NUM2INT(*(RARRAY_PTR(ary))), | | 813 | + NUM2INT(*(RARRAY_PTR(ary))), |
788 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 814 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
789 | + NUM2INT(*(RARRAY_PTR(ary)+2)), | | 815 | + NUM2INT(*(RARRAY_PTR(ary)+2)), |
790 | NUM2INT(a)); | | 816 | NUM2INT(a)); |
791 | return INT2NUM(c); | | 817 | return INT2NUM(c); |
792 | @@ -2183,7 +2205,7 @@ img_color_closest_alpha_str(img, rgbstr, | | 818 | @@ -2183,7 +2188,7 @@ img_color_closest_alpha_str(img, rgbstr, |
793 | ary = hex2triplet(rgbstr); | | 819 | ary = hex2triplet(rgbstr); |
794 | c = gdImageColorClosestAlpha(im, | | 820 | c = gdImageColorClosestAlpha(im, |
795 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 821 | - NUM2INT(*(RARRAY(ary)->ptr)), |
796 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 822 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
797 | - NUM2INT(*(RARRAY(ary)->ptr+2)), | | 823 | - NUM2INT(*(RARRAY(ary)->ptr+2)), |
798 | + NUM2INT(*(RARRAY_PTR(ary))), | | 824 | + NUM2INT(*(RARRAY_PTR(ary))), |
799 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 825 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
800 | + NUM2INT(*(RARRAY_PTR(ary)+2)), | | 826 | + NUM2INT(*(RARRAY_PTR(ary)+2)), |
801 | NUM2INT(a)); | | 827 | NUM2INT(a)); |
802 | return INT2NUM(c); | | 828 | return INT2NUM(c); |
803 | @@ -2245,7 +2267,7 @@ img_color_exact_alpha_str(img, rgbstr, a | | 829 | @@ -2245,7 +2250,7 @@ img_color_exact_alpha_str(img, rgbstr, a |
804 | ary = hex2triplet(rgbstr); | | 830 | ary = hex2triplet(rgbstr); |
805 | c = gdImageColorExactAlpha(im, | | 831 | c = gdImageColorExactAlpha(im, |
806 | - NUM2INT(*(RARRAY(ary)->ptr)), | | 832 | - NUM2INT(*(RARRAY(ary)->ptr)), |
807 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 833 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
808 | - NUM2INT(*(RARRAY(ary)->ptr+2)), | | 834 | - NUM2INT(*(RARRAY(ary)->ptr+2)), |
809 | + NUM2INT(*(RARRAY_PTR(ary))), | | 835 | + NUM2INT(*(RARRAY_PTR(ary))), |
810 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 836 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
811 | + NUM2INT(*(RARRAY_PTR(ary)+2)), | | 837 | + NUM2INT(*(RARRAY_PTR(ary)+2)), |
812 | NUM2INT(a)); | | 838 | NUM2INT(a)); |
813 | return INT2NUM(c); | | 839 | return INT2NUM(c); |
814 | @@ -2311,7 +2333,7 @@ img_s_truecolor_str(rgbstr) | | 840 | @@ -2311,7 +2316,7 @@ img_s_truecolor_str(rgbstr) |
815 | VALUE ary; | | 841 | VALUE ary; |
816 | ary = hex2triplet(rgbstr); | | 842 | ary = hex2triplet(rgbstr); |
817 | - c = gdTrueColor(NUM2INT(*(RARRAY(ary)->ptr)), | | 843 | - c = gdTrueColor(NUM2INT(*(RARRAY(ary)->ptr)), |
818 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 844 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
819 | - NUM2INT(*(RARRAY(ary)->ptr+2))); | | 845 | - NUM2INT(*(RARRAY(ary)->ptr+2))); |
820 | + c = gdTrueColor(NUM2INT(*(RARRAY_PTR(ary))), | | 846 | + c = gdTrueColor(NUM2INT(*(RARRAY_PTR(ary))), |
821 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 847 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
822 | + NUM2INT(*(RARRAY_PTR(ary)+2))); | | 848 | + NUM2INT(*(RARRAY_PTR(ary)+2))); |
823 | | | 849 | |
824 | return INT2NUM(c); | | 850 | return INT2NUM(c); |
825 | @@ -2365,7 +2387,7 @@ img_s_truecolor_alpha_str(rgbstr, a) | | 851 | @@ -2365,7 +2370,7 @@ img_s_truecolor_alpha_str(rgbstr, a) |
826 | VALUE ary; | | 852 | VALUE ary; |
827 | ary = hex2triplet(rgbstr); | | 853 | ary = hex2triplet(rgbstr); |
828 | - c = gdTrueColorAlpha(NUM2INT(*(RARRAY(ary)->ptr)), | | 854 | - c = gdTrueColorAlpha(NUM2INT(*(RARRAY(ary)->ptr)), |
829 | - NUM2INT(*(RARRAY(ary)->ptr+1)), | | 855 | - NUM2INT(*(RARRAY(ary)->ptr+1)), |
830 | - NUM2INT(*(RARRAY(ary)->ptr+2)), | | 856 | - NUM2INT(*(RARRAY(ary)->ptr+2)), |
831 | + c = gdTrueColorAlpha(NUM2INT(*(RARRAY_PTR(ary))), | | 857 | + c = gdTrueColorAlpha(NUM2INT(*(RARRAY_PTR(ary))), |
832 | + NUM2INT(*(RARRAY_PTR(ary)+1)), | | 858 | + NUM2INT(*(RARRAY_PTR(ary)+1)), |
833 | + NUM2INT(*(RARRAY_PTR(ary)+2)), | | 859 | + NUM2INT(*(RARRAY_PTR(ary)+2)), |
834 | NUM2INT(a)); | | 860 | NUM2INT(a)); |
835 | return INT2NUM(c); | | 861 | return INT2NUM(c); |