6 /* Copyright (C) 1998, 2000, 2001, 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but 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.
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 02110-1301 USA
25 #include "libguile/__scm.h"
27 #include "libguile/validate.h"
31 SCM_API
int scm_module_system_booted_p
;
32 SCM_API scm_t_bits scm_module_tag
;
34 #define SCM_MODULEP(OBJ) \
35 (!SCM_IMP (OBJ) && SCM_CELL_TYPE (OBJ) == scm_module_tag)
37 #define SCM_VALIDATE_MODULE(pos, scm) SCM_MAKE_VALIDATE_MSG (pos, scm, MODULEP, "module")
39 /* NOTE: Indexes of module fields are dependent upon the definition of
40 * module-type in boot-9.scm.
43 #define scm_module_index_obarray 0
44 #define scm_module_index_uses 1
45 #define scm_module_index_binder 2
46 #define scm_module_index_eval_closure 3
47 #define scm_module_index_transformer 4
48 #define scm_module_index_duplicate_handlers 7
49 #define scm_module_index_import_obarray 8
51 #define SCM_MODULE_OBARRAY(module) \
52 SCM_PACK (SCM_STRUCT_DATA (module) [scm_module_index_obarray])
53 #define SCM_MODULE_USES(module) \
54 SCM_PACK (SCM_STRUCT_DATA (module) [scm_module_index_uses])
55 #define SCM_MODULE_BINDER(module) \
56 SCM_PACK (SCM_STRUCT_DATA (module) [scm_module_index_binder])
57 #define SCM_MODULE_EVAL_CLOSURE(module) \
58 SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_eval_closure])
59 #define SCM_MODULE_TRANSFORMER(module) \
60 SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_transformer])
61 #define SCM_MODULE_DUPLICATE_HANDLERS(module) \
62 SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_duplicate_handlers])
63 #define SCM_MODULE_IMPORT_OBARRAY(module) \
64 SCM_PACK (SCM_STRUCT_DATA (module)[scm_module_index_import_obarray])
66 SCM_API scm_t_bits scm_tc16_eval_closure
;
68 #define SCM_EVAL_CLOSURE_P(x) SCM_TYP16_PREDICATE (scm_tc16_eval_closure, x)
72 SCM_API SCM
scm_current_module (void);
73 SCM_API SCM
scm_module_variable (SCM module
, SCM sym
);
74 SCM_API SCM
scm_module_local_variable (SCM module
, SCM sym
);
75 SCM_API SCM
scm_interaction_environment (void);
76 SCM_API SCM
scm_set_current_module (SCM module
);
78 SCM_API SCM
scm_c_call_with_current_module (SCM module
,
79 SCM (*func
)(void *), void *data
);
80 SCM_API
void scm_dynwind_current_module (SCM module
);
82 SCM_API SCM
scm_c_lookup (const char *name
);
83 SCM_API SCM
scm_c_define (const char *name
, SCM val
);
84 SCM_API SCM
scm_lookup (SCM symbol
);
85 SCM_API SCM
scm_define (SCM symbol
, SCM val
);
87 SCM_API SCM
scm_c_module_lookup (SCM module
, const char *name
);
88 SCM_API SCM
scm_c_module_define (SCM module
, const char *name
, SCM val
);
89 SCM_API SCM
scm_module_lookup (SCM module
, SCM symbol
);
90 SCM_API SCM
scm_module_define (SCM module
, SCM symbol
, SCM val
);
91 SCM_API SCM
scm_module_export (SCM module
, SCM symbol_list
);
92 SCM_API SCM
scm_module_reverse_lookup (SCM module
, SCM variable
);
94 SCM_API SCM
scm_c_resolve_module (const char *name
);
95 SCM_API SCM
scm_resolve_module (SCM name
);
96 SCM_API SCM
scm_c_define_module (const char *name
,
97 void (*init
)(void *), void *data
);
98 SCM_API
void scm_c_use_module (const char *name
);
99 SCM_API
void scm_c_export (const char *name
, ...);
101 SCM_API SCM
scm_sym2var (SCM sym
, SCM thunk
, SCM definep
);
103 SCM_API SCM
scm_module_import_interface (SCM module
, SCM sym
);
104 SCM_API SCM
scm_module_lookup_closure (SCM module
);
105 SCM_API SCM
scm_module_transformer (SCM module
);
106 SCM_API SCM
scm_current_module_lookup_closure (void);
107 SCM_API SCM
scm_current_module_transformer (void);
108 SCM_API SCM
scm_eval_closure_lookup (SCM eclo
, SCM sym
, SCM definep
);
109 SCM_API SCM
scm_standard_eval_closure (SCM module
);
110 SCM_API SCM
scm_standard_interface_eval_closure (SCM module
);
111 SCM_API SCM
scm_get_pre_modules_obarray (void);
112 SCM_API SCM
scm_lookup_closure_module (SCM proc
);
114 SCM_API SCM
scm_env_top_level (SCM env
);
115 SCM_API SCM
scm_env_module (SCM env
);
116 SCM_API SCM
scm_top_level_env (SCM thunk
);
117 SCM_API SCM
scm_system_module_env_p (SCM env
);
119 SCM_API
void scm_modules_prehistory (void);
120 SCM_API
void scm_init_modules (void);
122 #endif /* SCM_MODULES_H */