modules.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef SCM_MODULES_H
  2. #define SCM_MODULES_H
  3. /* Copyright 1998,2000-2003,2006-2008,2011-2012,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/gc.h"
  18. SCM_API int scm_module_system_booted_p;
  19. SCM_API scm_t_bits scm_module_tag;
  20. #define SCM_MODULEP(OBJ) \
  21. (!SCM_IMP (OBJ) && SCM_CELL_TYPE (OBJ) == scm_module_tag)
  22. #define SCM_VALIDATE_MODULE(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, MODULEP, "module")
  23. /* NOTE: Indexes of module fields are dependent upon the definition of
  24. * module-type in boot-9.scm.
  25. */
  26. #define scm_module_index_obarray 0
  27. #define scm_module_index_uses 1
  28. #define scm_module_index_binder 2
  29. #define scm_module_index_eval_closure 3
  30. #define scm_module_index_transformer 4
  31. #define scm_module_index_duplicate_handlers 7
  32. #define scm_module_index_import_obarray 8
  33. #define SCM_MODULE_OBARRAY(module) \
  34. SCM_PACK (SCM_STRUCT_DATA (module) [scm_module_index_obarray])
  35. #define SCM_MODULE_USES(module) \
  36. SCM_PACK (SCM_STRUCT_DATA (module) [scm_module_index_uses])
  37. #define SCM_MODULE_BINDER(module) \
  38. SCM_PACK (SCM_STRUCT_DATA (module) [scm_module_index_binder])
  39. #define SCM_MODULE_EVAL_CLOSURE(module) \
  40. SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_eval_closure])
  41. #define SCM_MODULE_TRANSFORMER(module) \
  42. SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_transformer])
  43. #define SCM_MODULE_DUPLICATE_HANDLERS(module) \
  44. SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_duplicate_handlers])
  45. #define SCM_MODULE_IMPORT_OBARRAY(module) \
  46. SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_import_obarray])
  47. SCM_API SCM scm_current_module (void);
  48. SCM_INTERNAL SCM scm_i_current_module (scm_thread *thread);
  49. SCM_API SCM scm_the_root_module (void);
  50. SCM_API SCM scm_interaction_environment (void);
  51. SCM_API SCM scm_set_current_module (SCM module);
  52. SCM_API SCM scm_c_call_with_current_module (SCM module,
  53. SCM (*func)(void *), void *data);
  54. SCM_API void scm_dynwind_current_module (SCM module);
  55. SCM_API SCM scm_module_variable (SCM module, SCM sym);
  56. SCM_API SCM scm_module_local_variable (SCM module, SCM sym);
  57. SCM_API SCM scm_module_ensure_local_variable (SCM module, SCM sym);
  58. SCM_API SCM scm_c_lookup (const char *name);
  59. SCM_API SCM scm_c_define (const char *name, SCM val);
  60. SCM_API SCM scm_lookup (SCM symbol);
  61. SCM_API SCM scm_define (SCM symbol, SCM val);
  62. SCM_API SCM scm_c_module_lookup (SCM module, const char *name);
  63. SCM_API SCM scm_c_module_define (SCM module, const char *name, SCM val);
  64. SCM_API SCM scm_module_lookup (SCM module, SCM symbol);
  65. SCM_API SCM scm_module_define (SCM module, SCM symbol, SCM val);
  66. SCM_API SCM scm_module_export (SCM module, SCM symbol_list);
  67. SCM_API SCM scm_module_reverse_lookup (SCM module, SCM variable);
  68. SCM_API SCM scm_public_variable (SCM module_name, SCM name);
  69. SCM_API SCM scm_private_variable (SCM module_name, SCM name);
  70. SCM_API SCM scm_c_public_variable (const char *module_name, const char *name);
  71. SCM_API SCM scm_c_private_variable (const char *module_name, const char *name);
  72. SCM_API SCM scm_public_lookup (SCM module_name, SCM name);
  73. SCM_API SCM scm_private_lookup (SCM module_name, SCM name);
  74. SCM_API SCM scm_c_public_lookup (const char *module_name, const char *name);
  75. SCM_API SCM scm_c_private_lookup (const char *module_name, const char *name);
  76. SCM_API SCM scm_public_ref (SCM module_name, SCM name);
  77. SCM_API SCM scm_private_ref (SCM module_name, SCM name);
  78. SCM_API SCM scm_c_public_ref (const char *module_name, const char *name);
  79. SCM_API SCM scm_c_private_ref (const char *module_name, const char *name);
  80. SCM_API SCM scm_c_resolve_module (const char *name);
  81. SCM_API SCM scm_resolve_module (SCM name);
  82. SCM_API SCM scm_maybe_resolve_module (SCM name);
  83. SCM_API SCM scm_c_define_module (const char *name,
  84. void (*init)(void *), void *data);
  85. SCM_API void scm_c_use_module (const char *name);
  86. SCM_API void scm_c_export (const char *name, ...);
  87. SCM_API SCM scm_module_public_interface (SCM module);
  88. SCM_API SCM scm_module_import_interface (SCM module, SCM sym);
  89. SCM_API SCM scm_module_transformer (SCM module);
  90. SCM_API SCM scm_current_module_transformer (void);
  91. SCM_API SCM scm_get_pre_modules_obarray (void);
  92. SCM_INTERNAL void scm_modules_prehistory (void);
  93. SCM_INTERNAL void scm_init_modules (void);
  94. #endif /* SCM_MODULES_H */