2 |
- |
1 |
/* Copyright (C) 1993, 1995, 1998, 1999 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: iparam.h,v 1.5 2002/06/16 04:47:10 lpd Exp $ */
|
|
|
18 |
/* Definitions and interface for interpreter parameter list implementations */
|
|
|
19 |
/* Requires ialloc.h, istack.h */
|
|
|
20 |
|
|
|
21 |
#ifndef iparam_INCLUDED
|
|
|
22 |
# define iparam_INCLUDED
|
|
|
23 |
|
|
|
24 |
#include "gsparam.h"
|
|
|
25 |
|
|
|
26 |
/*
|
|
|
27 |
* This file defines the interface to iparam.c, which provides
|
|
|
28 |
* several implementations of the parameter dictionary interface
|
|
|
29 |
* defined in gsparam.h:
|
|
|
30 |
* - an implementation using dictionary objects;
|
|
|
31 |
* - an implementation using name/value pairs in an array;
|
|
|
32 |
* - an implementation using name/value pairs on a stack.
|
|
|
33 |
*
|
|
|
34 |
* When reading ('putting'), these implementations keep track of
|
|
|
35 |
* which parameters have been referenced and which have caused errors.
|
|
|
36 |
* The results array contains 0 for a parameter that has not been accessed,
|
|
|
37 |
* 1 for a parameter accessed without error, or <0 for an error.
|
|
|
38 |
*/
|
|
|
39 |
|
|
|
40 |
typedef struct iparam_loc_s {
|
|
|
41 |
ref *pvalue; /* (actually const) */
|
|
|
42 |
int *presult;
|
|
|
43 |
} iparam_loc;
|
|
|
44 |
|
|
|
45 |
#define iparam_list_common\
|
|
|
46 |
gs_param_list_common;\
|
|
|
47 |
gs_ref_memory_t *ref_memory; /* a properly typed copy of memory */\
|
|
|
48 |
union {\
|
|
|
49 |
struct { /* reading */\
|
|
|
50 |
int (*read)(iparam_list *, const ref *, iparam_loc *);\
|
|
|
51 |
ref policies; /* policy dictionary or null */\
|
|
|
52 |
bool require_all; /* if true, require all params to be known */\
|
|
|
53 |
} r;\
|
|
|
54 |
struct { /* writing */\
|
|
|
55 |
int (*write)(iparam_list *, const ref *, const ref *);\
|
|
|
56 |
ref wanted; /* desired keys or null */\
|
|
|
57 |
} w;\
|
|
|
58 |
} u;\
|
|
|
59 |
int (*enumerate)(iparam_list *, gs_param_enumerator_t *, gs_param_key_t *, ref_type *);\
|
|
|
60 |
int *results; /* (only used when reading, 0 when writing) */\
|
|
|
61 |
uint count; /* # of key/value pairs */\
|
|
|
62 |
bool int_keys /* if true, keys are integers */
|
|
|
63 |
typedef struct iparam_list_s iparam_list;
|
|
|
64 |
struct iparam_list_s {
|
|
|
65 |
iparam_list_common;
|
|
|
66 |
};
|
|
|
67 |
|
|
|
68 |
typedef struct dict_param_list_s {
|
|
|
69 |
iparam_list_common;
|
|
|
70 |
ref dict; /* dictionary or array */
|
|
|
71 |
} dict_param_list;
|
|
|
72 |
typedef struct array_param_list_s {
|
|
|
73 |
iparam_list_common;
|
|
|
74 |
ref *bot;
|
|
|
75 |
ref *top;
|
|
|
76 |
} array_param_list;
|
|
|
77 |
|
|
|
78 |
/* For stack lists, the bottom of the list is just above a mark. */
|
|
|
79 |
typedef struct stack_param_list_s {
|
|
|
80 |
iparam_list_common;
|
|
|
81 |
ref_stack_t *pstack;
|
|
|
82 |
uint skip; /* # of top items to skip (reading only) */
|
|
|
83 |
} stack_param_list;
|
|
|
84 |
|
|
|
85 |
/* Procedural interface */
|
|
|
86 |
/*
|
|
|
87 |
* For dict_param_list_read (only), the second parameter may be NULL,
|
|
|
88 |
* equivalent to an empty dictionary.
|
|
|
89 |
* The 3rd (const ref *) parameter is the policies dictionary when reading,
|
|
|
90 |
* or the key selection dictionary when writing; it may be NULL in either case.
|
|
|
91 |
* If the bool parameter is true, if there are any unqueried parameters,
|
|
|
92 |
* the commit procedure will return an e_undefined error.
|
|
|
93 |
*/
|
|
|
94 |
int dict_param_list_read(dict_param_list *, const ref * /*t_dictionary */ ,
|
|
|
95 |
const ref *, bool, gs_ref_memory_t *);
|
|
|
96 |
int dict_param_list_write(dict_param_list *, ref * /*t_dictionary */ ,
|
|
|
97 |
const ref *, gs_ref_memory_t *);
|
|
|
98 |
int array_indexed_param_list_read(dict_param_list *, const ref * /*t_*array */ ,
|
|
|
99 |
const ref *, bool, gs_ref_memory_t *);
|
|
|
100 |
int array_indexed_param_list_write(dict_param_list *, ref * /*t_*array */ ,
|
|
|
101 |
const ref *, gs_ref_memory_t *);
|
|
|
102 |
int array_param_list_read(array_param_list *, ref *, uint,
|
|
|
103 |
const ref *, bool, gs_ref_memory_t *);
|
|
|
104 |
int stack_param_list_read(stack_param_list *, ref_stack_t *, uint,
|
|
|
105 |
const ref *, bool, gs_ref_memory_t *);
|
|
|
106 |
int stack_param_list_write(stack_param_list *, ref_stack_t *,
|
|
|
107 |
const ref *, gs_ref_memory_t *);
|
|
|
108 |
|
|
|
109 |
#define iparam_list_release(plist)\
|
|
|
110 |
gs_free_object((plist)->memory, (plist)->results, "iparam_list_release")
|
|
|
111 |
|
|
|
112 |
#endif /* iparam_INCLUDED */
|