1 /* Copyright (C) 2001-2019 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., 1305 Grant Avenue - Suite 200, Novato, 13 CA 94945, U.S.A., +1(415)492-9861, for further information. 14 */ 15 16 17 /* Definitions for "PostScript Calculator" Functions */ 18 19 #ifndef gsfunc4_INCLUDED 20 # define gsfunc4_INCLUDED 21 22 #include "gsfunc.h" 23 24 /* ---------------- Types and structures ---------------- */ 25 26 /* Define the Function type. */ 27 #define function_type_PostScript_Calculator 4 28 29 #define MAX_PSC_FUNCTION_NESTING 10 30 31 /* Define the opcodes. */ 32 typedef enum { 33 34 /* Arithmetic operators */ 35 36 PtCr_abs, PtCr_add, PtCr_and, PtCr_atan, PtCr_bitshift, 37 PtCr_ceiling, PtCr_cos, PtCr_cvi, PtCr_cvr, PtCr_div, PtCr_exp, 38 PtCr_floor, PtCr_idiv, PtCr_ln, PtCr_log, PtCr_mod, PtCr_mul, 39 PtCr_neg, PtCr_not, PtCr_or, PtCr_round, 40 PtCr_sin, PtCr_sqrt, PtCr_sub, PtCr_truncate, PtCr_xor, 41 42 /* Comparison operators */ 43 44 PtCr_eq, PtCr_ge, PtCr_gt, PtCr_le, PtCr_lt, PtCr_ne, 45 46 /* Stack operators */ 47 48 PtCr_copy, PtCr_dup, PtCr_exch, PtCr_index, PtCr_pop, PtCr_roll, 49 50 /* Constants */ 51 52 PtCr_byte, PtCr_int /* native */, PtCr_float /* native */, 53 PtCr_true, PtCr_false, 54 55 /* Special operators */ 56 57 PtCr_if, PtCr_else, PtCr_return, 58 PtCr_repeat, PtCr_repeat_end, /* Ghostscript extension */ 59 PtCr_end /* dummy to make it easier to insert opcodes above */ 60 } gs_PtCr_opcode_t; 61 #define PtCr_NUM_OPS ((int)PtCr_byte) 62 #define PtCr_NUM_OPCODES ((int)PtCr_end + 1) 63 64 /* Define PostScript Calculator functions. */ 65 typedef struct gs_function_PtCr_params_s { 66 gs_function_params_common; 67 gs_const_string ops; /* gs_PtCr_opcode_t[] */ 68 } gs_function_PtCr_params_t; 69 70 /****** NEEDS TO INCLUDE data_source ******/ 71 #define private_st_function_PtCr() /* in gsfunc4.c */\ 72 gs_private_st_suffix_add_strings1(st_function_PtCr, gs_function_PtCr_t,\ 73 "gs_function_PtCr_t", function_PtCr_enum_ptrs, function_PtCr_reloc_ptrs,\ 74 st_function, params.ops) 75 76 /* ---------------- Procedures ---------------- */ 77 78 /* Allocate and initialize a PostScript Calculator function. */ 79 int gs_function_PtCr_init(gs_function_t ** ppfn, 80 const gs_function_PtCr_params_t * params, 81 gs_memory_t * mem); 82 83 /* Free the parameters of a PostScript Calculator function. */ 84 void gs_function_PtCr_free_params(gs_function_PtCr_params_t * params, 85 gs_memory_t * mem); 86 87 #endif /* gsfunc4_INCLUDED */ 88