6 /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003 Free Software Foundation, Inc.
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.
13 * This library 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 GNU
16 * Lesser General Public License for more details.
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
25 #include "libguile/__scm.h"
28 /* SCM_SYMBOL_LENGTH(SYM) is the length of SYM's name in characters, and
29 * SCM_SYMBOL_CHARS(SYM) is the address of the first character of SYM's name.
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.
36 #define SCM_SYMBOLP(x) (!SCM_IMP (x) && (SCM_TYP7 (x) == scm_tc7_symbol))
37 #define SCM_SYMBOL_LENGTH(x) (((unsigned long) SCM_CELL_WORD_0 (x)) >> 8)
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)))
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)))
42 #define SCM_SYMBOL_HASH(X) ((unsigned long) SCM_CELL_WORD_2 (X))
43 #define SCM_SYMBOL_INTERNED_P(X) (SCM_SYMBOL_HASH(X) <= (SCM_T_BITS_MAX/2))
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)))
55 SCM_API SCM
scm_sys_symbols (void);
57 SCM_API
unsigned long scm_i_hash_symbol (SCM obj
, unsigned long n
, void *closure
);
58 SCM_API SCM
scm_mem2symbol (const char*, size_t);
59 SCM_API SCM
scm_mem2uninterned_symbol (const char *name
, size_t len
);
60 SCM_API SCM
scm_str2symbol (const char*);
62 SCM_API SCM
scm_symbol_p (SCM x
);
63 SCM_API SCM
scm_symbol_interned_p (SCM sym
);
64 SCM_API SCM
scm_make_symbol (SCM name
);
65 SCM_API SCM
scm_symbol_to_string (SCM s
);
66 SCM_API SCM
scm_string_to_symbol (SCM s
);
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
);
73 SCM_API SCM
scm_symbol_hash (SCM s
);
74 SCM_API SCM
scm_gensym (SCM prefix
);
76 SCM_API
char *scm_c_symbol2str (SCM obj
, char *str
, size_t *lenp
);
77 SCM_API
void scm_symbols_prehistory (void);
78 SCM_API
void scm_init_symbols (void);
80 #endif /* SCM_SYMBOLS_H */