variable.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef SCM_VARIABLE_H
  2. #define SCM_VARIABLE_H
  3. /* Copyright 1995-1996,2000-2001,2006,2008,2011,2018
  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/gc.h>
  19. #include <libguile/snarf.h>
  20. /* Variables
  21. */
  22. #define SCM_VARIABLEP(X) (SCM_HAS_TYP7 (X, scm_tc7_variable))
  23. #define SCM_VARIABLE_REF(V) SCM_CELL_OBJECT_1 (V)
  24. #define SCM_VARIABLE_SET(V, X) SCM_SET_CELL_OBJECT_1 (V, X)
  25. #define SCM_VARIABLE_LOC(V) (SCM_CELL_OBJECT_LOC ((V), 1))
  26. #define SCM_VALIDATE_VARIABLE(pos, var) \
  27. SCM_MAKE_VALIDATE_MSG (pos, var, VARIABLEP, "variable")
  28. #define SCM_VARIABLE(c_name, scheme_name) \
  29. SCM_SNARF_HERE(static SCM c_name) \
  30. SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, SCM_BOOL_F);)
  31. #define SCM_GLOBAL_VARIABLE(c_name, scheme_name) \
  32. SCM_SNARF_HERE(SCM c_name) \
  33. SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, SCM_BOOL_F);)
  34. #define SCM_VARIABLE_INIT(c_name, scheme_name, init_val) \
  35. SCM_SNARF_HERE(static SCM c_name) \
  36. SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, init_val);)
  37. #define SCM_GLOBAL_VARIABLE_INIT(c_name, scheme_name, init_val) \
  38. SCM_SNARF_HERE(SCM c_name) \
  39. SCM_SNARF_INIT(c_name = scm_c_define (scheme_name, init_val);)
  40. SCM_API SCM scm_make_variable (SCM init);
  41. SCM_API SCM scm_make_undefined_variable (void);
  42. SCM_API SCM scm_variable_p (SCM obj);
  43. SCM_API SCM scm_variable_ref (SCM var);
  44. SCM_API SCM scm_variable_set_x (SCM var, SCM val);
  45. SCM_API SCM scm_variable_unset_x (SCM var);
  46. SCM_API SCM scm_variable_bound_p (SCM var);
  47. SCM_INTERNAL void scm_i_variable_print (SCM var, SCM port, scm_print_state *pstate);
  48. SCM_INTERNAL void scm_init_variable (void);
  49. #endif /* SCM_VARIABLE_H */