Prefixed each each exported symbol with SCM_API.
[bpt/guile.git] / libguile / srcprop.h
1 /* classes: h_files */
2
3 #ifndef SCM_SRCPROP_H
4 #define SCM_SRCPROP_H
5
6 /* Copyright (C) 1995,1996,2000,2001 Free Software Foundation, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this software; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307 USA
22 *
23 * As a special exception, the Free Software Foundation gives permission
24 * for additional uses of the text contained in its release of GUILE.
25 *
26 * The exception is that, if you link the GUILE library with other files
27 * to produce an executable, this does not by itself cause the
28 * resulting executable to be covered by the GNU General Public License.
29 * Your use of that executable is in no way restricted on account of
30 * linking the GUILE library code into it.
31 *
32 * This exception does not however invalidate any other reasons why
33 * the executable file might be covered by the GNU General Public License.
34 *
35 * This exception applies only to the code released by the
36 * Free Software Foundation under the name GUILE. If you copy
37 * code from other Free Software Foundation releases into a copy of
38 * GUILE, as the General Public License permits, the exception does
39 * not apply to the code that you add in this way. To avoid misleading
40 * anyone as to the status of such modified files, you must delete
41 * this exception notice from them.
42 *
43 * If you write modifications of your own for GUILE, it is your choice
44 * whether to permit this exception to apply to your modifications.
45 * If you do not wish that, delete this exception notice.
46 *
47 * The author can be reached at djurfeldt@nada.kth.se
48 * Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */
49
50 \f
51
52 #include "libguile/__scm.h"
53
54 \f
55
56 /* {The old whash table interface}
57 * *fixme* This is a temporary solution until weak hash table access
58 * has been optimized for speed (which is quite necessary, if they are
59 * used for recording of source code positions...)
60 */
61
62 #define scm_whash_handle SCM
63
64 #define scm_whash_get_handle(whash, key) scm_hash_fn_get_handle (whash, key, scm_ihashq, scm_sloppy_assq, 0)
65 #define SCM_WHASHFOUNDP(h) (!SCM_FALSEP (h))
66 #define SCM_WHASHREF(whash, handle) SCM_CDR (handle)
67 #define SCM_WHASHSET(whash, handle, obj) SCM_SETCDR (handle, obj)
68 #define scm_whash_create_handle(whash, key) scm_hash_fn_create_handle_x (whash, key, SCM_UNSPECIFIED, scm_ihashq, scm_sloppy_assq, 0)
69 #define scm_whash_lookup(whash, obj) scm_hash_fn_ref (whash, obj, SCM_BOOL_F, scm_ihashq, scm_sloppy_assq, 0)
70 #define scm_whash_insert(whash, key, obj) \
71 do { \
72 register SCM w = (whash); \
73 SCM_WHASHSET (w, scm_whash_create_handle (w, key), obj); \
74 } while (0)
75
76
77 /* {Source properties}
78 */
79
80 SCM_API scm_t_bits scm_tc16_srcprops;
81
82 typedef struct scm_t_srcprops
83 {
84 unsigned long pos;
85 SCM fname;
86 SCM copy;
87 SCM plist;
88 } scm_t_srcprops;
89
90 #define SRCPROPS_CHUNKSIZE 2047 /* Number of srcprops per chunk */
91 typedef struct scm_t_srcprops_chunk
92 {
93 struct scm_t_srcprops_chunk *next;
94 scm_t_srcprops srcprops[1];
95 } scm_t_srcprops_chunk;
96
97 #define SCM_SOURCE_PROPERTY_FLAG_BREAK (1L << 16)
98
99 #define SRCPROPSP(p) (SCM_TYP16_PREDICATE (scm_tc16_srcprops, p))
100 #define SRCPROPBRK(p) \
101 (SCM_BOOL (SCM_CELL_WORD_0 (p) & SCM_SOURCE_PROPERTY_FLAG_BREAK))
102 #define SRCPROPPOS(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->pos
103 #define SRCPROPLINE(p) (SRCPROPPOS(p) >> 12)
104 #define SRCPROPCOL(p) (SRCPROPPOS(p) & 0x0fffL)
105 #define SRCPROPFNAME(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->fname
106 #define SRCPROPCOPY(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->copy
107 #define SRCPROPPLIST(p) ((scm_t_srcprops *) SCM_CELL_WORD_1 (p))->plist
108 #define SETSRCPROPBRK(p) \
109 (SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) \
110 | SCM_SOURCE_PROPERTY_FLAG_BREAK))
111 #define CLEARSRCPROPBRK(p) \
112 (SCM_SET_CELL_WORD_0 ((p), SCM_CELL_WORD_0 (p) \
113 & ~SCM_SOURCE_PROPERTY_FLAG_BREAK))
114 #define SRCPROPMAKPOS(l,c) (((l) << 12) + (c))
115 #define SETSRCPROPPOS(p,l,c) (SRCPROPPOS (p) = SRCPROPMAKPOS (l, c))
116 #define SETSRCPROPLINE(p,l) SETSRCPROPPOS (p, l, SRCPROPCOL (p))
117 #define SETSRCPROPCOL(p,c) SETSRCPROPPOS (p, SRCPROPLINE (p), c)
118
119 #define SRCBRKP(x) (!SCM_IMP (t.arg1 = scm_whash_lookup (scm_source_whash, (x)))\
120 && SRCPROPSP (t.arg1)\
121 && (SCM_CELL_WORD_0 (t.arg1) & (1L << 16)))
122
123 #define PROCTRACEP(x) (!SCM_FALSEP (scm_procedure_property (x, scm_sym_trace)))
124
125 SCM_API SCM scm_sym_filename;
126 SCM_API SCM scm_sym_copy;
127 SCM_API SCM scm_sym_line;
128 SCM_API SCM scm_sym_column;
129 SCM_API SCM scm_sym_breakpoint;
130
131 \f
132
133
134 SCM_API SCM scm_srcprops_to_plist (SCM obj);
135 SCM_API SCM scm_make_srcprops (long line, int col, SCM fname, SCM copy, SCM plist);
136 SCM_API SCM scm_source_property (SCM obj, SCM key);
137 SCM_API SCM scm_set_source_property_x (SCM obj, SCM key, SCM datum);
138 SCM_API SCM scm_source_properties (SCM obj);
139 SCM_API SCM scm_set_source_properties_x (SCM obj, SCM props);
140 SCM_API void scm_finish_srcprop (void);
141 SCM_API void scm_init_srcprop (void);
142
143 #endif /* SCM_SRCPROP_H */
144
145 /*
146 Local Variables:
147 c-file-style: "gnu"
148 End:
149 */