xref: /plan9/sys/src/cmd/gs/src/gsfunc4.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 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: gsfunc4.h,v 1.5 2002/06/16 08:45:42 lpd Exp $ */
18 /* Definitions for "PostScript Calculator" Functions */
19 
20 #ifndef gsfunc4_INCLUDED
21 #  define gsfunc4_INCLUDED
22 
23 #include "gsfunc.h"
24 
25 /* ---------------- Types and structures ---------------- */
26 
27 /* Define the Function type. */
28 #define function_type_PostScript_Calculator 4
29 
30 /* Define the opcodes. */
31 typedef enum {
32 
33     /* Arithmetic operators */
34 
35     PtCr_abs, PtCr_add, PtCr_and, PtCr_atan, PtCr_bitshift,
36     PtCr_ceiling, PtCr_cos, PtCr_cvi, PtCr_cvr, PtCr_div, PtCr_exp,
37     PtCr_floor, PtCr_idiv, PtCr_ln, PtCr_log, PtCr_mod, PtCr_mul,
38     PtCr_neg, PtCr_not, PtCr_or, PtCr_round,
39     PtCr_sin, PtCr_sqrt, PtCr_sub, PtCr_truncate, PtCr_xor,
40 
41     /* Comparison operators */
42 
43     PtCr_eq, PtCr_ge, PtCr_gt, PtCr_le, PtCr_lt, PtCr_ne,
44 
45     /* Stack operators */
46 
47     PtCr_copy, PtCr_dup, PtCr_exch, PtCr_index, PtCr_pop, PtCr_roll,
48 
49     /* Constants */
50 
51     PtCr_byte, PtCr_int /* native */, PtCr_float /* native */,
52     PtCr_true, PtCr_false,
53 
54     /* Special operators */
55 
56     PtCr_if, PtCr_else, PtCr_return
57 
58 } gs_PtCr_opcode_t;
59 #define PtCr_NUM_OPS ((int)PtCr_byte)
60 #define PtCr_NUM_OPCODES ((int)PtCr_return + 1)
61 
62 /* Define PostScript Calculator functions. */
63 typedef struct gs_function_PtCr_params_s {
64     gs_function_params_common;
65     gs_const_string ops;	/* gs_PtCr_opcode_t[] */
66 } gs_function_PtCr_params_t;
67 
68 /****** NEEDS TO INCLUDE data_source ******/
69 #define private_st_function_PtCr()	/* in gsfunc4.c */\
70   gs_private_st_suffix_add_strings1(st_function_PtCr, gs_function_PtCr_t,\
71     "gs_function_PtCr_t", function_PtCr_enum_ptrs, function_PtCr_reloc_ptrs,\
72     st_function, params.ops)
73 
74 /* ---------------- Procedures ---------------- */
75 
76 /* Allocate and initialize a PostScript Calculator function. */
77 int gs_function_PtCr_init(gs_function_t ** ppfn,
78 			  const gs_function_PtCr_params_t * params,
79 			  gs_memory_t * mem);
80 
81 /* Free the parameters of a PostScript Calculator function. */
82 void gs_function_PtCr_free_params(gs_function_PtCr_params_t * params,
83 				  gs_memory_t * mem);
84 
85 #endif /* gsfunc4_INCLUDED */
86