/src/ghostpdl/psi/iutil.h
Line | Count | Source |
1 | | /* Copyright (C) 2001-2026 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* Interface to interpreter utilities */ |
18 | | /* Requires imemory.h, ostack.h */ |
19 | | |
20 | | #ifndef iutil_INCLUDED |
21 | | # define iutil_INCLUDED |
22 | | |
23 | | #include "imemory.h" |
24 | | #include "gsmatrix.h" |
25 | | |
26 | | /* ------ Object utilities ------ */ |
27 | | |
28 | | /* Copy refs from one place to another. */ |
29 | | /* (If we are copying to the stack, we can just use memcpy.) */ |
30 | | void refcpy_to_new(ref * to, const ref * from, uint size, |
31 | | gs_dual_memory_t *dmem); |
32 | | int refcpy_to_old(ref * aref, uint index, const ref * from, uint size, |
33 | | gs_dual_memory_t *dmem, client_name_t cname); |
34 | | |
35 | | /* |
36 | | * Fill an array with nulls. |
37 | | * For backward compatibility, we define the procedure with a new name. |
38 | | */ |
39 | | void refset_null_new(ref * to, uint size, uint new_mask); |
40 | 819M | #define refset_null(to, size) refset_null_new(to, size, ialloc_new_mask) |
41 | | |
42 | | /* Compare two objects for equality. */ |
43 | | bool obj_eq(const gs_memory_t *mem, const ref *, const ref *); |
44 | | |
45 | | /* Compare two objects for identity. */ |
46 | | /* (This is not a standard PostScript concept.) */ |
47 | | bool obj_ident_eq(const gs_memory_t *mem, const ref *, const ref *); |
48 | | |
49 | | /* |
50 | | * Set *pchars and *plen to point to the data of a name or string, and |
51 | | * return 0. If the object isn't a name or string, return gs_error_typecheck. |
52 | | * If the object is a string without read access, return gs_error_invalidaccess. |
53 | | */ |
54 | | int obj_string_data(const gs_memory_t *mem, const ref *op, const byte **pchars, uint *plen); |
55 | | |
56 | | /* |
57 | | * Create a printable representation of an object, a la cvs and = |
58 | | * (full_print = 0), == (full_print = 1), or === (full_print = 2). Return 0 |
59 | | * if OK, 1 if the destination wasn't large enough, gs_error_invalidaccess if the |
60 | | * object's contents weren't readable. If the return value is 0 or 1, |
61 | | * *prlen contains the amount of data returned. start_pos is the starting |
62 | | * output position -- the first start_pos bytes of output are discarded. |
63 | | * |
64 | | * The mem argument is only used for getting the type of structures, |
65 | | * not for allocating; if it is NULL and full_print != 0, structures will |
66 | | * print as --(struct)--. |
67 | | */ |
68 | 2.56M | #define CVP_MAX_STRING 200 /* strings are truncated here if full_print = 1 */ |
69 | | int obj_cvp(const ref * op, byte *str, uint len, uint * prlen, |
70 | | int full_print, uint start_pos, const gs_memory_t *mem, bool restart); |
71 | | |
72 | | /* |
73 | | * Create a printable representation of an object, a la cvs and =. Return 0 |
74 | | * if OK, gs_error_rangecheck if the destination wasn't large enough, |
75 | | * gs_error_invalidaccess if the object's contents weren't readable. If pchars != |
76 | | * NULL, then if the object was a string or name, store a pointer to its |
77 | | * characters in *pchars even if it was too large; otherwise, set *pchars = |
78 | | * str. In any case, store the length in *prlen. |
79 | | * |
80 | | * obj_cvs is different from obj_cvp in two respects: if the printed |
81 | | * representation is too large, it returns gs_error_rangecheck rather than 1; |
82 | | * and it can return a pointer to the data for names and strings, like |
83 | | * obj_string_data. |
84 | | */ |
85 | | int obj_cvs(const gs_memory_t *mem, const ref * op, byte * str, uint len, uint * prlen, |
86 | | const byte ** pchars); |
87 | | |
88 | | /* Get an element from an array (packed or not). */ |
89 | | int array_get(const gs_memory_t *mem, const ref *, long, ref *); |
90 | | |
91 | | static inline int array_get_with_type(const gs_memory_t *mem, const ref *aref, long index_long, ref *pref, ref_type type) |
92 | 1.55M | { |
93 | 1.55M | int code = array_get(mem, aref, index_long, pref); |
94 | 1.55M | if (code >= 0) |
95 | 1.55M | if ((type == t_array) ? !r_is_array(pref) : !r_has_type(pref, type)) |
96 | 0 | code = gs_note_error(gs_error_typecheck); |
97 | 1.55M | return code; |
98 | 1.55M | } Unexecuted instantiation: imain.c:array_get_with_type Unexecuted instantiation: zbseq.c:array_get_with_type Unexecuted instantiation: zcolor1.c:array_get_with_type Unexecuted instantiation: zht1.c:array_get_with_type Unexecuted instantiation: zupath.c:array_get_with_type Unexecuted instantiation: ibnum.c:array_get_with_type Unexecuted instantiation: zcharx.c:array_get_with_type Unexecuted instantiation: zvmem2.c:array_get_with_type Unexecuted instantiation: zdps1.c:array_get_with_type Unexecuted instantiation: zfcid0.c:array_get_with_type Unexecuted instantiation: zfcid1.c:array_get_with_type Unexecuted instantiation: zchar1.c:array_get_with_type Unexecuted instantiation: zcharout.c:array_get_with_type Unexecuted instantiation: zfont1.c:array_get_with_type Unexecuted instantiation: zmisc1.c:array_get_with_type Unexecuted instantiation: zmisc2.c:array_get_with_type Unexecuted instantiation: zusparam.c:array_get_with_type Unexecuted instantiation: zchar2.c:array_get_with_type Unexecuted instantiation: zfont2.c:array_get_with_type Unexecuted instantiation: zchar42.c:array_get_with_type Unexecuted instantiation: zfont42.c:array_get_with_type Unexecuted instantiation: zfrsd.c:array_get_with_type Unexecuted instantiation: zcrd.c:array_get_with_type Unexecuted instantiation: zfcmap.c:array_get_with_type Unexecuted instantiation: zcfont.c:array_get_with_type Unexecuted instantiation: zfont0.c:array_get_with_type Unexecuted instantiation: zfdcte.c:array_get_with_type Unexecuted instantiation: zfdctd.c:array_get_with_type Unexecuted instantiation: zfdecode.c:array_get_with_type Unexecuted instantiation: zfilter2.c:array_get_with_type Unexecuted instantiation: ziodev2.c:array_get_with_type Unexecuted instantiation: zdevice2.c:array_get_with_type Unexecuted instantiation: zmedia2.c:array_get_with_type Unexecuted instantiation: zpcolor.c:array_get_with_type Unexecuted instantiation: idisp.c:array_get_with_type Unexecuted instantiation: idebug.c:array_get_with_type Unexecuted instantiation: idict.c:array_get_with_type Unexecuted instantiation: idparam.c:array_get_with_type Unexecuted instantiation: idstack.c:array_get_with_type Unexecuted instantiation: iinit.c:array_get_with_type Unexecuted instantiation: interp.c:array_get_with_type Unexecuted instantiation: iparam.c:array_get_with_type Unexecuted instantiation: iscan.c:array_get_with_type Unexecuted instantiation: istack.c:array_get_with_type Unexecuted instantiation: iutil.c:array_get_with_type Unexecuted instantiation: zarith.c:array_get_with_type Unexecuted instantiation: zarray.c:array_get_with_type Unexecuted instantiation: zcontrol.c:array_get_with_type Unexecuted instantiation: zdict.c:array_get_with_type Unexecuted instantiation: zfile.c:array_get_with_type Unexecuted instantiation: zfile1.c:array_get_with_type Unexecuted instantiation: zfileio.c:array_get_with_type Unexecuted instantiation: zfilter.c:array_get_with_type Unexecuted instantiation: zfproc.c:array_get_with_type Unexecuted instantiation: zgeneric.c:array_get_with_type Unexecuted instantiation: ziodev.c:array_get_with_type Unexecuted instantiation: ziodevsc.c:array_get_with_type Unexecuted instantiation: zmath.c:array_get_with_type Unexecuted instantiation: zalg.c:array_get_with_type Unexecuted instantiation: zmisc.c:array_get_with_type Unexecuted instantiation: zpacked.c:array_get_with_type Unexecuted instantiation: zrelbit.c:array_get_with_type Unexecuted instantiation: zstack.c:array_get_with_type Unexecuted instantiation: zstring.c:array_get_with_type Unexecuted instantiation: zsysvm.c:array_get_with_type Unexecuted instantiation: ztoken.c:array_get_with_type Unexecuted instantiation: ztype.c:array_get_with_type Unexecuted instantiation: zvmem.c:array_get_with_type Unexecuted instantiation: zbfont.c:array_get_with_type Unexecuted instantiation: zchar.c:array_get_with_type Unexecuted instantiation: zcolor.c:array_get_with_type Unexecuted instantiation: zdevice.c:array_get_with_type Unexecuted instantiation: zfont.c:array_get_with_type Unexecuted instantiation: zfontenum.c:array_get_with_type Unexecuted instantiation: zgstate.c:array_get_with_type Unexecuted instantiation: zht.c:array_get_with_type Unexecuted instantiation: zimage.c:array_get_with_type Unexecuted instantiation: zmatrix.c:array_get_with_type Unexecuted instantiation: zpaint.c:array_get_with_type Unexecuted instantiation: zpath.c:array_get_with_type Unexecuted instantiation: zncdummy.c:array_get_with_type Unexecuted instantiation: ialloc.c:array_get_with_type Unexecuted instantiation: ilocate.c:array_get_with_type Unexecuted instantiation: zdscpars.c:array_get_with_type zfapi.c:array_get_with_type Line | Count | Source | 92 | 1.55M | { | 93 | 1.55M | int code = array_get(mem, aref, index_long, pref); | 94 | 1.55M | if (code >= 0) | 95 | 1.55M | if ((type == t_array) ? !r_is_array(pref) : !r_has_type(pref, type)) | 96 | 0 | code = gs_note_error(gs_error_typecheck); | 97 | 1.55M | return code; | 98 | 1.55M | } |
Unexecuted instantiation: zpath1.c:array_get_with_type Unexecuted instantiation: zcsindex.c:array_get_with_type Unexecuted instantiation: zht2.c:array_get_with_type Unexecuted instantiation: zcssepr.c:array_get_with_type Unexecuted instantiation: zfsample.c:array_get_with_type Unexecuted instantiation: zfunc4.c:array_get_with_type Unexecuted instantiation: zfunc.c:array_get_with_type Unexecuted instantiation: zfunc0.c:array_get_with_type Unexecuted instantiation: zchar32.c:array_get_with_type Unexecuted instantiation: zfont32.c:array_get_with_type Unexecuted instantiation: zfimscale.c:array_get_with_type Unexecuted instantiation: zform.c:array_get_with_type Unexecuted instantiation: zfunc3.c:array_get_with_type Unexecuted instantiation: zimage3.c:array_get_with_type Unexecuted instantiation: zmisc3.c:array_get_with_type Unexecuted instantiation: zcolor3.c:array_get_with_type Unexecuted instantiation: zshade.c:array_get_with_type Unexecuted instantiation: zfzlib.c:array_get_with_type Unexecuted instantiation: zicc.c:array_get_with_type Unexecuted instantiation: ztrans.c:array_get_with_type Unexecuted instantiation: zpdfops.c:array_get_with_type Unexecuted instantiation: imainarg.c:array_get_with_type Unexecuted instantiation: iscanbin.c:array_get_with_type Unexecuted instantiation: zcid.c:array_get_with_type Unexecuted instantiation: zfcid.c:array_get_with_type Unexecuted instantiation: iutil2.c:array_get_with_type Unexecuted instantiation: zcie.c:array_get_with_type |
99 | | |
100 | | /* Get an element from a packed array. */ |
101 | | /* (This works for ordinary arrays too.) */ |
102 | | /* Source and destination are allowed to overlap if the source is packed, */ |
103 | | /* or if they are identical. */ |
104 | | void packed_get(const gs_memory_t *mem, const ref_packed *, ref *); |
105 | | |
106 | | /* Check to make sure an interval contains no object references */ |
107 | | /* to a space younger than a given one. */ |
108 | | /* Return 0 or gs_error_invalidaccess. */ |
109 | | int refs_check_space(const ref * refs, uint size, uint space); |
110 | | |
111 | | /* ------ String utilities ------ */ |
112 | | |
113 | | /* Convert a C string to a string object. */ |
114 | | int string_to_ref(const char *, ref *, gs_ref_memory_t *, client_name_t); |
115 | | |
116 | | /* Convert a string object to a C string. */ |
117 | | /* Return 0 iff the buffer can't be allocated. */ |
118 | | char *ref_to_string(const ref *, gs_memory_t *, client_name_t); |
119 | | |
120 | | /* ------ Operand utilities ------ */ |
121 | | |
122 | | /* Get N numeric operands from the stack or an array. */ |
123 | | int num_params(const ref *, int, double *); |
124 | | |
125 | | /* float_params can lose accuracy for large integers. */ |
126 | | int float_params(const ref *, int, float *); |
127 | | |
128 | | /* process_float_array can lose accuracy for large integers */ |
129 | | int process_float_array(const gs_memory_t *mem, const ref *, int, float *); |
130 | | |
131 | | /* Get a single real parameter. */ |
132 | | /* The only possible error is gs_error_typecheck. */ |
133 | | int real_param(const ref *, double *); |
134 | | |
135 | | /* float_param can lose accuracy for large integers. */ |
136 | | int float_param(const ref *, float *); |
137 | | |
138 | | /* Get an integer parameter in a given range. */ |
139 | | int int_param(const ref *, int, int *); |
140 | | |
141 | | /* Make real values on the stack. */ |
142 | | /* Return gs_error_limitcheck for infinities or double->float overflow. */ |
143 | | int make_reals(ref *, const double *, int); |
144 | | int make_floats(ref *, const float *, int); |
145 | | |
146 | | /* Read a matrix operand. */ |
147 | | int read_matrix(const gs_memory_t *mem, const ref *, gs_matrix *); |
148 | | |
149 | | /* Write a matrix operand. */ |
150 | | /* If dmem is NULL, the array is guaranteed newly allocated in imem. */ |
151 | | /* If dmem is not NULL, imem is ignored. */ |
152 | | int write_matrix_in(ref *op, const gs_matrix *pmat, gs_dual_memory_t *dmem, |
153 | | gs_ref_memory_t *imem); |
154 | | #define write_matrix_new(op, pmat, imem)\ |
155 | 49.4k | write_matrix_in(op, pmat, NULL, imem) |
156 | | #define write_matrix(op, pmat)\ |
157 | 2.20M | write_matrix_in(op, pmat, idmemory, NULL) |
158 | | |
159 | | #endif /* iutil_INCLUDED */ |