1 /* Copyright (C) 2001-2006 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, modified
8    or distributed except as expressly authorized under the terms of that
9    license.  Refer to licensing information at http://www.artifex.com/
10    or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11    San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12 */
13 
14 /* $Id: iname.h 9043 2008-08-28 22:48:19Z giles $ */
15 /* Interpreter's name table interface */
16 
17 #ifndef iname_INCLUDED
18 #  define iname_INCLUDED
19 
20 #include "inames.h"
21 
22 /*
23  * This file defines those parts of the name table API that refer to the
24  * interpreter's distinguished instance.  Procedures in this file begin
25  * with name_.
26  */
27 
28 /* ---------------- Procedural interface ---------------- */
29 
30 
31 /* Get the allocator for the name table. */
32 #define name_memory(mem)\
33   names_memory(mem->gs_lib_ctx->gs_name_table)
34 
35 /*
36  * Look up and/or enter a name in the name table.
37  * See inames.h for the values of enterflag, and the possible return values.
38  */
39 #define name_ref(mem, ptr, size, pnref, enterflag)\
40   names_ref(mem->gs_lib_ctx->gs_name_table, ptr, size, pnref, enterflag)
41 #define name_string_ref(mem, pnref, psref)\
42   names_string_ref(mem->gs_lib_ctx->gs_name_table, pnref, psref)
43 /*
44  * name_enter_string calls name_ref with a (permanent) C string.
45  */
46 #define name_enter_string(mem, str, pnref)\
47   names_enter_string(mem->gs_lib_ctx->gs_name_table, str, pnref)
48 /*
49  * name_from_string essentially implements cvn.
50  * It always enters the name, and copies the executable attribute.
51  */
52 #define name_from_string(mem, psref, pnref)\
53   names_from_string(mem->gs_lib_ctx->gs_name_table, psref, pnref)
54 
55 /* Compare two names for equality. */
56 #define name_eq(pnref1, pnref2)\
57   names_eq(pnref1, pnref2)
58 
59 /* Invalidate the value cache for a name. */
60 #define name_invalidate_value_cache(mem, pnref)\
61   names_invalidate_value_cache(mem->gs_lib_ctx->gs_name_table, pnref)
62 
63 /* Convert between names and indices. */
64 #define name_index(mem, pnref)		/* ref => index */\
65   names_index(mem->gs_lib_ctx->gs_name_table, pnref)
66 #define name_index_ptr(mem, nidx)		/* index => name */\
67   names_index_ptr(mem->gs_lib_ctx->gs_name_table, nidx)
68 #define name_index_ref(mem, nidx, pnref)	/* index => ref */\
69   names_index_ref(mem->gs_lib_ctx->gs_name_table, nidx, pnref)
70 
71 /* Get the index of the next valid name. */
72 /* The argument is 0 or a valid index. */
73 /* Return 0 if there are no more. */
74 #define name_next_valid_index(mem, nidx)\
75   names_next_valid_index(mem->gs_lib_ctx->gs_name_table, nidx)
76 
77 /* Mark a name for the garbage collector. */
78 /* Return true if this is a new mark. */
79 #define name_mark_index(mem, nidx)\
80   names_mark_index(mem->gs_lib_ctx->gs_name_table, nidx)
81 
82 /* Get the object (sub-table) containing a name. */
83 /* The garbage collector needs this so it can relocate pointers to names. */
84 #define name_ref_sub_table(mem, pnref)\
85   names_ref_sub_table(mem->gs_lib_ctx->gs_name_table, pnref)
86 
87 #endif /* iname_INCLUDED */
88