xref: /plan9/sys/src/cmd/gs/src/ifunc.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1997, 2000 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: ifunc.h,v 1.10 2002/10/31 18:34:25 alexcher Exp $ */
18 /* Internal interpreter interfaces for Functions */
19 
20 #ifndef ifunc_INCLUDED
21 #  define ifunc_INCLUDED
22 
23 #include "gsfunc.h"
24 
25 /* Define build procedures for the various function types. */
26 #define build_function_proc(proc)\
27   int proc(i_ctx_t *i_ctx_p, const ref *op, const gs_function_params_t *params, int depth,\
28 	   gs_function_t **ppfn, gs_memory_t *mem)
29 typedef build_function_proc((*build_function_proc_t));
30 
31 /* Define the table of build procedures, indexed by FunctionType. */
32 typedef struct build_function_type_s {
33     int type;
34     build_function_proc_t proc;
35 } build_function_type_t;
36 extern const build_function_type_t build_function_type_table[];
37 extern const uint build_function_type_table_count;
38 
39 /* Build a function structure from a PostScript dictionary. */
40 int fn_build_function(i_ctx_t *i_ctx_p, const ref * op, gs_function_t ** ppfn,
41 		      gs_memory_t *mem);
42 int fn_build_sub_function(i_ctx_t *i_ctx_p, const ref * op, gs_function_t ** ppfn,
43 			  int depth, gs_memory_t *mem);
44 
45 /*
46  * Collect a heap-allocated array of floats.  If the key is missing, set
47  * *pparray = 0 and return 0; otherwise set *pparray and return the number
48  * of elements.  Note that 0-length arrays are acceptable, so if the value
49  * returned is 0, the caller must check whether *pparray == 0.
50  */
51 int fn_build_float_array(const ref * op, const char *kstr, bool required,
52 			 bool even, const float **pparray,
53 			 gs_memory_t *mem);
54 
55 /*
56  * Similar to fn_build_float_array() except
57  * - numeric parameter is accepted and converted to 1-element array
58  * - number of elements is not checked for even/odd
59  */
60 int
61 fn_build_float_array_forced(const ref * op, const char *kstr, bool required,
62 		     const float **pparray, gs_memory_t *mem);
63 
64 
65 /*
66  * If a PostScript object is a Function procedure, return the function
67  * object, otherwise return 0.
68  */
69 gs_function_t *ref_function(const ref *op);
70 
71 /*
72  * Operator to execute a function.
73  * <in1> ... <function_struct> %execfunction <out1> ...
74  */
75 int zexecfunction(i_ctx_t *);
76 
77 #endif /* ifunc_INCLUDED */
78