Commit | Line | Data |
---|---|---|
0f2d19dd JB |
1 | /* classes: h_files */ |
2 | ||
729dbac3 DH |
3 | #ifndef SCM_SYMBOLS_H |
4 | #define SCM_SYMBOLS_H | |
dee01b01 | 5 | |
c35738c1 | 6 | /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003 Free Software Foundation, Inc. |
dee01b01 | 7 | * |
73be1d9e MV |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2.1 of the License, or (at your option) any later version. | |
dee01b01 | 12 | * |
73be1d9e | 13 | * This library is distributed in the hope that it will be useful, |
0f2d19dd | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
dee01b01 | 17 | * |
73be1d9e MV |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
d3a6bc94 | 22 | |
0f2d19dd JB |
23 | \f |
24 | ||
b4309c3c | 25 | #include "libguile/__scm.h" |
0f2d19dd JB |
26 | \f |
27 | ||
2d349e67 | 28 | /* SCM_SYMBOL_LENGTH(SYM) is the length of SYM's name in characters, and |
a002f1a2 | 29 | * SCM_SYMBOL_CHARS(SYM) is the address of the first character of SYM's name. |
ac48757b MV |
30 | * |
31 | * SCM_SYMBOL_HASH is a hash value for the symbol. It is also used to | |
32 | * encode whether the symbol is interned or not. See | |
33 | * SCM_SYMBOL_INTERNED_P. | |
28b06554 | 34 | */ |
8ce94504 | 35 | |
dee01b01 | 36 | #define SCM_SYMBOLP(x) (!SCM_IMP (x) && (SCM_TYP7 (x) == scm_tc7_symbol)) |
c014a02e | 37 | #define SCM_SYMBOL_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8) |
0a7b506d MV |
38 | #define SCM_MAKE_SYMBOL_TAG(l) (((l) << 8) + scm_tc7_symbol) |
39 | #define SCM_SET_SYMBOL_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), SCM_MAKE_SYMBOL_TAG(l))) | |
e51fe79c DH |
40 | #define SCM_SYMBOL_CHARS(x) ((char *) (SCM_CELL_WORD_1 (x))) |
41 | #define SCM_SET_SYMBOL_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c))) | |
c014a02e | 42 | #define SCM_SYMBOL_HASH(X) ((unsigned long) SCM_CELL_WORD_2 (X)) |
ac48757b | 43 | #define SCM_SYMBOL_INTERNED_P(X) (SCM_SYMBOL_HASH(X) <= (SCM_T_BITS_MAX/2)) |
3210f49a | 44 | |
729dbac3 DH |
45 | #define SCM_PROP_SLOTS(X) (SCM_CELL_OBJECT_3 (X)) |
46 | #define SCM_SET_PROP_SLOTS(X, v) (SCM_SET_CELL_OBJECT_3 ((X), (v))) | |
47 | #define SCM_SYMBOL_FUNC(X) (SCM_CAR (SCM_CELL_OBJECT_3 (X))) | |
48 | #define SCM_SET_SYMBOL_FUNC(X, v) (SCM_SETCAR (SCM_CELL_OBJECT_3 (X), (v))) | |
49 | #define SCM_SYMBOL_PROPS(X) (SCM_CDR (SCM_CELL_OBJECT_3 (X))) | |
50 | #define SCM_SET_SYMBOL_PROPS(X, v) (SCM_SETCDR (SCM_CELL_OBJECT_3 (X), (v))) | |
0f2d19dd | 51 | |
0f2d19dd | 52 | \f |
0f2d19dd | 53 | |
a4c91488 | 54 | #ifdef GUILE_DEBUG |
33b001fd | 55 | SCM_API SCM scm_sys_symbols (void); |
a4c91488 | 56 | #endif |
c35738c1 | 57 | SCM_API unsigned long scm_i_hash_symbol (SCM obj, unsigned long n, void *closure); |
33b001fd | 58 | SCM_API SCM scm_mem2symbol (const char*, size_t); |
a63cdd61 | 59 | SCM_API SCM scm_mem2uninterned_symbol (const char *name, size_t len); |
33b001fd | 60 | SCM_API SCM scm_str2symbol (const char*); |
23ade5e7 | 61 | |
33b001fd | 62 | SCM_API SCM scm_symbol_p (SCM x); |
a63cdd61 MV |
63 | SCM_API SCM scm_symbol_interned_p (SCM sym); |
64 | SCM_API SCM scm_make_symbol (SCM name); | |
33b001fd MV |
65 | SCM_API SCM scm_symbol_to_string (SCM s); |
66 | SCM_API SCM scm_string_to_symbol (SCM s); | |
86d31dfe | 67 | |
33b001fd MV |
68 | SCM_API SCM scm_symbol_fref (SCM s); |
69 | SCM_API SCM scm_symbol_pref (SCM s); | |
70 | SCM_API SCM scm_symbol_fset_x (SCM s, SCM val); | |
71 | SCM_API SCM scm_symbol_pset_x (SCM s, SCM val); | |
86d31dfe | 72 | |
33b001fd MV |
73 | SCM_API SCM scm_symbol_hash (SCM s); |
74 | SCM_API SCM scm_gensym (SCM prefix); | |
86d31dfe | 75 | |
af68e5e5 | 76 | SCM_API char *scm_c_symbol2str (SCM obj, char *str, size_t *lenp); |
33b001fd MV |
77 | SCM_API void scm_symbols_prehistory (void); |
78 | SCM_API void scm_init_symbols (void); | |
0f2d19dd | 79 | |
729dbac3 | 80 | #endif /* SCM_SYMBOLS_H */ |
89e00824 ML |
81 | |
82 | /* | |
83 | Local Variables: | |
84 | c-file-style: "gnu" | |
85 | End: | |
86 | */ |