gstypes.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Copyright (C) 1989, 1995, 1998, 2001 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: gstypes.h,v 1.3 2001/08/25 06:46:21 lpd Exp $ */
  16. /* Miscellaneous common types for Ghostscript library */
  17. #ifndef gstypes_INCLUDED
  18. # define gstypes_INCLUDED
  19. /*
  20. * Define a type used internally for unique IDs of various kinds
  21. * (primarily, but not exclusively, character and halftone bitmaps).
  22. * These IDs bear no relation to any other ID space; we generate them all
  23. * ourselves.
  24. */
  25. typedef ulong gs_id;
  26. #define gs_no_id 0L
  27. /*
  28. * Define a sensible representation of a string, as opposed to
  29. * the C char * type (which can't store arbitrary data, represent
  30. * substrings, or perform concatenation without destroying aliases).
  31. *
  32. * If a byte * pointer P is the result of allocating a string of size N,
  33. * then any substring of [P .. P+N) is a valid gs_string, i.e., any
  34. * gs_string S is valid (until the string is deallocated) if it has P <=
  35. * S.data and S.data + S.size <= P + N.
  36. */
  37. #define GS_STRING_COMMON\
  38. byte *data;\
  39. uint size
  40. typedef struct gs_string_s {
  41. GS_STRING_COMMON;
  42. } gs_string;
  43. #define GS_CONST_STRING_COMMON\
  44. const byte *data;\
  45. uint size
  46. typedef struct gs_const_string_s {
  47. GS_CONST_STRING_COMMON;
  48. } gs_const_string;
  49. /*
  50. * Since strings are allocated differently from ordinary objects, define a
  51. * structure that can reference either a string or a byte object. If bytes
  52. * == 0, data and size are the same as for a gs_string. If bytes != 0, data
  53. * and size point within the object addressed by bytes (i.e., the bytes
  54. * member plays the role of P in the consistency condition given for
  55. * gs_string above). Thus in either case, code can process the string using
  56. * only data and size: bytes is only relevant for garbage collection.
  57. *
  58. * Note: for garbage collection purposes, the string_common members must
  59. * come first.
  60. */
  61. typedef struct gs_bytestring_s {
  62. GS_STRING_COMMON;
  63. byte *bytes; /* see above */
  64. } gs_bytestring;
  65. typedef struct gs_const_bytestring_s {
  66. GS_CONST_STRING_COMMON;
  67. const byte *bytes; /* see above */
  68. } gs_const_bytestring;
  69. #define gs_bytestring_from_string(pbs, dat, siz)\
  70. ((pbs)->data = (dat), (pbs)->size = (siz), (pbs)->bytes = 0)
  71. #define gs_bytestring_from_bytes(pbs, byts, offset, siz)\
  72. ((pbs)->data = ((pbs)->bytes = (byts)) + (offset), (pbs)->size = (siz))
  73. /*
  74. * Define types for Cartesian points.
  75. */
  76. typedef struct gs_point_s {
  77. double x, y;
  78. } gs_point;
  79. typedef struct gs_int_point_s {
  80. int x, y;
  81. } gs_int_point;
  82. /*
  83. * Define a scale for oversampling. Clients don't actually use this,
  84. * but this seemed like the handiest place for it.
  85. */
  86. typedef struct gs_log2_scale_point_s {
  87. int x, y;
  88. } gs_log2_scale_point;
  89. /*
  90. * Define types for rectangles in the Cartesian plane.
  91. * Note that rectangles are half-open, i.e.: their width is
  92. * q.x-p.x and their height is q.y-p.y; they include the points
  93. * (x,y) such that p.x<=x<q.x and p.y<=y<q.y.
  94. */
  95. typedef struct gs_rect_s {
  96. gs_point p, q; /* origin point, corner point */
  97. } gs_rect;
  98. typedef struct gs_int_rect_s {
  99. gs_int_point p, q;
  100. } gs_int_rect;
  101. #endif /* gstypes_INCLUDED */