Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- added version/level to the API function table structure

  • Loading branch information...
commit d1f5892c122cd93e9be46cd4dddd031a85102c4f 1 parent 89d3718
Tony Cook authored
1  Changes
@@ -1360,6 +1360,7 @@ Revision history for Perl extension Imager.
1360 1360 - IM_DEBUG_MALLOC wasn't interacting well with the API
1361 1361 - make win32.c const happy
1362 1362 - make raw.c C89 compliant
  1363 +- added version/level to the API function table structure
1363 1364
1364 1365 =================================================================
1365 1366
3  imext.c
@@ -6,6 +6,9 @@
6 6 */
7 7 im_ext_funcs imager_function_table =
8 8 {
  9 + IMAGER_API_VERSION,
  10 + IMAGER_API_LEVEL,
  11 +
9 12 mymalloc,
10 13 myfree,
11 14 myrealloc,
14 imext.h
@@ -7,8 +7,20 @@ extern im_ext_funcs *imager_function_ext_table;
7 7
8 8 #define DEFINE_IMAGER_CALLBACKS im_ext_funcs *imager_function_ext_table
9 9
  10 +#ifndef IMAGER_MIN_API_LEVEL
  11 +#define IMAGER_MIN_API_LEVEL IMAGER_API_LEVEL
  12 +#endif
  13 +
10 14 #define PERL_INITIALIZE_IMAGER_CALLBACKS \
11   - imager_function_ext_table = INT2PTR(im_ext_funcs *, SvIV(get_sv(PERL_FUNCTION_TABLE_NAME, 1)))
  15 + do { \
  16 + imager_function_ext_table = INT2PTR(im_ext_funcs *, SvIV(get_sv(PERL_FUNCTION_TABLE_NAME, 1))); \
  17 + if (!imager_function_ext_table) \
  18 + croak("Imager API function table not found!"); \
  19 + if (imager_function_ext_table->version != IMAGER_API_VERSION) \
  20 + croak("Imager API version incorrect"); \
  21 + if (imager_function_ext_table->level < IMAGER_MIN_API_LEVEL) \
  22 + croak("API level %d below minimum of %d", imager_function_ext_table->level, IMAGER_MIN_API_LEVEL); \
  23 + } while (0)
12 24
13 25 /* just for use here */
14 26 #define im_extt imager_function_ext_table
21 imexttypes.h
@@ -5,7 +5,26 @@
5 5
6 6 #include "imdatatypes.h"
7 7
  8 +/*
  9 + IMAGER_API_VERSION is similar to the version number in the third and
  10 + fourth bytes of TIFF files - if it ever changes then the API has changed
  11 + too much for any application to remain compatible.
  12 +*/
  13 +#define IMAGER_API_VERSION 1
  14 +
  15 +/*
  16 + IMAGER_API_LEVEL is the level of the structure. New function pointers
  17 + will always remain at the end (unless IMAGER_API_VERSION changes), and
  18 + will result in an increment of IMAGER_API_LEVEL.
  19 +*/
  20 +
  21 +#define IMAGER_API_LEVEL 1
  22 +
8 23 typedef struct {
  24 + int version;
  25 + int level;
  26 +
  27 + /* IMAGER_API_LEVEL 1 functions */
9 28 void * (*f_mymalloc)(int size);
10 29 void (*f_myfree)(void *block);
11 30 void * (*f_myrealloc)(void *block, size_t newsize);
@@ -115,6 +134,8 @@ typedef struct {
115 134 void (*f_i_copyto_trans)(i_img *im, i_img *src, int x1, int y1, int x2, int y2, int tx, int ty, const i_color *trans);
116 135 i_img *(*f_i_copy)(i_img *im);
117 136 int (*f_i_rubthru)(i_img *im, i_img *src, int tx, int ty, int src_minx, int src_miny, int src_maxx, int src_maxy);
  137 +
  138 + /* IMAGER_API_LEVEL 2 functions will be added here */
118 139 } im_ext_funcs;
119 140
120 141 #define PERL_FUNCTION_TABLE_NAME "Imager::__ext_func_table"
36 lib/Imager/APIRef.pm
@@ -161,7 +161,7 @@ Returns the number of pixels retrieved.
161 161
162 162
163 163 =for comment
164   -From: Line 199 in imext.c
  164 +From: Line 202 in imext.c
165 165
166 166 =item i_glinf(im, l, r, y, colors)
167 167
@@ -173,7 +173,7 @@ Returns the number of pixels retrieved.
173 173
174 174
175 175 =for comment
176   -From: Line 234 in imext.c
  176 +From: Line 237 in imext.c
177 177
178 178 =item i_gpal(im, x, r, y, indexes)
179 179
@@ -187,7 +187,7 @@ Always returns 0 for direct color images.
187 187
188 188
189 189 =for comment
190   -From: Line 298 in imext.c
  190 +From: Line 301 in imext.c
191 191
192 192 =item i_gpix(im, x, y, color)
193 193
@@ -198,7 +198,7 @@ Returns 0 if the pixel was retrieved, or -1 if not.
198 198
199 199
200 200 =for comment
201   -From: Line 127 in imext.c
  201 +From: Line 130 in imext.c
202 202
203 203 =item i_gpixf(im, x, y, fcolor)
204 204
@@ -210,7 +210,7 @@ Returns 0 if the pixel was retrieved, or -1 if not.
210 210
211 211
212 212 =for comment
213   -From: Line 163 in imext.c
  213 +From: Line 166 in imext.c
214 214
215 215 =item i_gsamp(im, l, r, y, samp, chans, chan_count)
216 216
@@ -227,7 +227,7 @@ chan_count)
227 227
228 228
229 229 =for comment
230   -From: Line 252 in imext.c
  230 +From: Line 255 in imext.c
231 231
232 232 =item i_gsampf(im, l, r, y, samp, chans, chan_count)
233 233
@@ -244,7 +244,7 @@ chan_count)
244 244
245 245
246 246 =for comment
247   -From: Line 275 in imext.c
  247 +From: Line 278 in imext.c
248 248
249 249 =item i_line(im, x1, y1, x2, y2, val, endp)
250 250
@@ -284,7 +284,7 @@ Returns the number of pixels set.
284 284
285 285
286 286 =for comment
287   -From: Line 181 in imext.c
  287 +From: Line 184 in imext.c
288 288
289 289 =item i_plinf(im, l, r, fcolors)
290 290
@@ -296,7 +296,7 @@ Returns the number of pixels set.
296 296
297 297
298 298 =for comment
299   -From: Line 216 in imext.c
  299 +From: Line 219 in imext.c
300 300
301 301 =item i_ppal(im, x, r, y, indexes)
302 302
@@ -310,7 +310,7 @@ Always returns 0 for direct color images.
310 310
311 311
312 312 =for comment
313   -From: Line 317 in imext.c
  313 +From: Line 320 in imext.c
314 314
315 315 =item i_ppix(im, x, y, color)
316 316
@@ -324,7 +324,7 @@ color to the image.
324 324
325 325
326 326 =for comment
327   -From: Line 107 in imext.c
  327 +From: Line 110 in imext.c
328 328
329 329 =item i_ppixf(im, x, y, fcolor)
330 330
@@ -338,7 +338,7 @@ color to the image.
338 338
339 339
340 340 =for comment
341   -From: Line 144 in imext.c
  341 +From: Line 147 in imext.c
342 342
343 343
344 344 =back
@@ -715,7 +715,7 @@ Always fails for direct color images.
715 715
716 716
717 717 =for comment
718   -From: Line 336 in imext.c
  718 +From: Line 339 in imext.c
719 719
720 720 =item i_colorcount(im)
721 721
@@ -726,7 +726,7 @@ Returns -1 for direct images.
726 726
727 727
728 728 =for comment
729   -From: Line 382 in imext.c
  729 +From: Line 385 in imext.c
730 730
731 731 =item i_findcolor(im, color, &entry)
732 732
@@ -741,7 +741,7 @@ Always fails on direct color images.
741 741
742 742
743 743 =for comment
744   -From: Line 417 in imext.c
  744 +From: Line 420 in imext.c
745 745
746 746 =item i_getcolors(im, index, colors, count)
747 747
@@ -760,7 +760,7 @@ palette.
760 760
761 761
762 762 =for comment
763   -From: Line 357 in imext.c
  763 +From: Line 360 in imext.c
764 764
765 765 =item i_maxcolors(im)
766 766
@@ -772,7 +772,7 @@ Returns -1 for direct color images.
772 772
773 773
774 774 =for comment
775   -From: Line 399 in imext.c
  775 +From: Line 402 in imext.c
776 776
777 777 =item i_setcolors(im, index, colors, count)
778 778
@@ -790,7 +790,7 @@ Always fails on direct color images.
790 790
791 791
792 792 =for comment
793   -From: Line 437 in imext.c
  793 +From: Line 440 in imext.c
794 794
795 795
796 796 =back

0 comments on commit d1f5892

Please sign in to comment.
Something went wrong with that request. Please try again.