keywords.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SCM_KEYWORDS_H
  2. #define SCM_KEYWORDS_H
  3. /* Copyright 1995-1996,1999-2001,2006,2008,2015,2018-2019
  4. Free Software Foundation, Inc.
  5. This file is part of Guile.
  6. Guile is free software: you can redistribute it and/or modify it
  7. under the terms of the GNU Lesser General Public License as published
  8. by the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Guile is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with Guile. If not, see
  16. <https://www.gnu.org/licenses/>. */
  17. #include <libguile/error.h>
  18. #include <libguile/snarf.h>
  19. SCM_API SCM scm_keyword_p (SCM obj);
  20. SCM_API SCM scm_symbol_to_keyword (SCM symbol);
  21. SCM_API SCM scm_keyword_to_symbol (SCM keyword);
  22. SCM_API int scm_is_keyword (SCM val);
  23. SCM_API SCM scm_from_locale_keyword (const char *name);
  24. SCM_API SCM scm_from_locale_keywordn (const char *name, size_t len);
  25. SCM_API SCM scm_from_latin1_keyword (const char *name);
  26. SCM_API SCM scm_from_utf8_keyword (const char *name);
  27. #define SCM_VALIDATE_KEYWORD(pos, v) \
  28. SCM_MAKE_VALIDATE_MSG (pos, v, KEYWORDP, "keyword")
  29. #define SCM_KEYWORD(c_name, scheme_name) \
  30. SCM_SNARF_HERE(static SCM c_name) \
  31. SCM_SNARF_INIT(c_name = scm_from_utf8_keyword (scheme_name))
  32. #define SCM_GLOBAL_KEYWORD(c_name, scheme_name) \
  33. SCM_SNARF_HERE(SCM c_name) \
  34. SCM_SNARF_INIT(c_name = scm_from_utf8_keyword (scheme_name))
  35. enum scm_keyword_arguments_flags
  36. {
  37. SCM_ALLOW_OTHER_KEYS = (1U << 0),
  38. SCM_ALLOW_NON_KEYWORD_ARGUMENTS = (1U << 1)
  39. };
  40. typedef enum scm_keyword_arguments_flags scm_t_keyword_arguments_flags;
  41. SCM_API void
  42. scm_c_bind_keyword_arguments (const char *subr, SCM rest,
  43. scm_t_keyword_arguments_flags flags, ...);
  44. #define SCM_I_KEYWORD_HASH(x) scm_i_symbol_hash (SCM_CELL_OBJECT_1 (x))
  45. SCM_INTERNAL void scm_init_keywords (void);
  46. #endif /* SCM_KEYWORDS_H */