| 1 | /* classes: h_files */ |
| 2 | |
| 3 | #ifndef SCM_SYMBOLS_H |
| 4 | #define SCM_SYMBOLS_H |
| 5 | |
| 6 | /* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2004, 2006, 2008, 2010, 2011 Free Software Foundation, Inc. |
| 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Lesser General Public License |
| 10 | * as published by the Free Software Foundation; either version 3 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, but |
| 14 | * 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. |
| 17 | * |
| 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., 51 Franklin Street, Fifth Floor, Boston, MA |
| 21 | * 02110-1301 USA |
| 22 | */ |
| 23 | |
| 24 | \f |
| 25 | |
| 26 | #include "libguile/__scm.h" |
| 27 | \f |
| 28 | |
| 29 | #define scm_is_symbol(x) (SCM_HAS_TYP7 (x, scm_tc7_symbol)) |
| 30 | #define scm_i_symbol_hash(x) ((unsigned long) SCM_CELL_WORD_2 (x)) |
| 31 | #define scm_i_symbol_is_interned(x) \ |
| 32 | (!(SCM_CELL_WORD_0 (x) & SCM_I_F_SYMBOL_UNINTERNED)) |
| 33 | |
| 34 | #define SCM_I_F_SYMBOL_UNINTERNED 0x100 |
| 35 | |
| 36 | \f |
| 37 | |
| 38 | /* Older spellings; don't use in new code. |
| 39 | */ |
| 40 | #define SCM_SYMBOLP(x) (scm_is_symbol (x)) |
| 41 | #define SCM_SYMBOL_FUNC(x) (scm_symbol_fref (x)) |
| 42 | #define SCM_SET_SYMBOL_FUNC(x,f) (scm_symbol_fset_x (x, f)) |
| 43 | #define SCM_SYMBOL_PROPS(x) (scm_symbol_pref (x)) |
| 44 | #define SCM_SET_SYMBOL_PROPS(x,p) (scm_symbol_pset_x (x, p)) |
| 45 | #define SCM_SYMBOL_HASH(x) (scm_i_symbol_hash (x)) |
| 46 | #define SCM_SYMBOL_INTERNED_P(x) (scm_i_symbol_is_interned (x)) |
| 47 | |
| 48 | \f |
| 49 | |
| 50 | #ifdef GUILE_DEBUG |
| 51 | SCM_API SCM scm_sys_symbols (void); |
| 52 | #endif |
| 53 | |
| 54 | SCM_API SCM scm_symbol_p (SCM x); |
| 55 | SCM_API SCM scm_symbol_interned_p (SCM sym); |
| 56 | SCM_API SCM scm_make_symbol (SCM name); |
| 57 | SCM_API SCM scm_symbol_to_string (SCM s); |
| 58 | SCM_API SCM scm_string_to_symbol (SCM s); |
| 59 | SCM_API SCM scm_string_ci_to_symbol (SCM s); |
| 60 | |
| 61 | SCM_API SCM scm_symbol_fref (SCM s); |
| 62 | SCM_API SCM scm_symbol_pref (SCM s); |
| 63 | SCM_API SCM scm_symbol_fset_x (SCM s, SCM val); |
| 64 | SCM_API SCM scm_symbol_pset_x (SCM s, SCM val); |
| 65 | |
| 66 | SCM_API SCM scm_symbol_hash (SCM s); |
| 67 | SCM_API SCM scm_gensym (SCM prefix); |
| 68 | |
| 69 | /* Use locale encoding for user input, user output, or interacting with |
| 70 | the C library. Use latin-1 for ASCII, and for literals in source |
| 71 | code. Use UTF-8 for interaction with modern libraries which deal in |
| 72 | UTF-8. Otherwise use scm_to_stringn or scm_from_stringn, and |
| 73 | convert. */ |
| 74 | |
| 75 | SCM_API SCM scm_from_locale_symbol (const char *str); |
| 76 | SCM_API SCM scm_from_locale_symboln (const char *str, size_t len); |
| 77 | SCM_API SCM scm_take_locale_symbol (char *sym); |
| 78 | SCM_API SCM scm_take_locale_symboln (char *sym, size_t len); |
| 79 | |
| 80 | SCM_API SCM scm_from_latin1_symbol (const char *str); |
| 81 | SCM_API SCM scm_from_latin1_symboln (const char *str, size_t len); |
| 82 | SCM_API SCM scm_take_latin1_symbol (char *sym); |
| 83 | SCM_API SCM scm_take_latin1_symboln (char *sym, size_t len); |
| 84 | |
| 85 | SCM_API SCM scm_from_utf8_symbol (const char *str); |
| 86 | SCM_API SCM scm_from_utf8_symboln (const char *str, size_t len); |
| 87 | SCM_API SCM scm_take_utf8_symbol (char *sym); |
| 88 | SCM_API SCM scm_take_utf8_symboln (char *sym, size_t len); |
| 89 | |
| 90 | /* internal functions. */ |
| 91 | |
| 92 | SCM_INTERNAL unsigned long scm_i_hash_symbol (SCM obj, unsigned long n, |
| 93 | void *closure); |
| 94 | |
| 95 | SCM_INTERNAL void scm_symbols_prehistory (void); |
| 96 | SCM_INTERNAL void scm_init_symbols (void); |
| 97 | |
| 98 | #endif /* SCM_SYMBOLS_H */ |
| 99 | |
| 100 | /* |
| 101 | Local Variables: |
| 102 | c-file-style: "gnu" |
| 103 | End: |
| 104 | */ |