symbols.h 3.5 KB

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