summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-09-29 21:36:25 +0200
committerAndy Wingo <wingo@pobox.com>2008-09-29 21:36:25 +0200
commitdc68fdb961f1116c67c797ca07889ae21de40492 (patch)
tree2c48eff43727e407a94c252b33d08d9abe5c3424
parent46d2d6f80ebbb18e787434c4bfe2031f6182f652 (diff)
downloadguile-dc68fdb961f1116c67c797ca07889ae21de40492.tar.gz
move module-public-interface to C, and expose it as C API
* libguile/modules.h: * libguile/modules.c: * ice-9/boot-9.scm (module-public-interface): Move definition of module-public-interface to C, where it is now available as scm_module_public_interface ().
-rw-r--r--ice-9/boot-9.scm3
-rw-r--r--libguile/modules.c19
-rw-r--r--libguile/modules.h1
3 files changed, 21 insertions, 2 deletions
diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm
index bde0b852a..d3da2c645 100644
--- a/ice-9/boot-9.scm
+++ b/ice-9/boot-9.scm
@@ -1783,8 +1783,7 @@
;;; The directory of all modules and the standard root module.
;;;
-(define (module-public-interface m)
- (module-ref m '%module-public-interface #f))
+;; module-public-interface is defined in C.
(define (set-module-public-interface! m i)
(module-define! m '%module-public-interface i))
(define (set-system-module! m s)
diff --git a/libguile/modules.c b/libguile/modules.c
index d99d3e472..92fa4d365 100644
--- a/libguile/modules.c
+++ b/libguile/modules.c
@@ -620,6 +620,25 @@ SCM_DEFINE (scm_module_import_interface, "module-import-interface", 2, 0, 0,
}
#undef FUNC_NAME
+SCM_SYMBOL (sym_sys_module_public_interface, "%module-public-interface");
+
+SCM_DEFINE (scm_module_public_interface, "module-public-interface", 1, 0, 0,
+ (SCM module),
+ "Return the public interface of @var{module}.\n\n"
+ "If @var{module} has no public interface, @code{#f} is returned.")
+#define FUNC_NAME s_scm_module_public_interface
+{
+ SCM var;
+
+ SCM_VALIDATE_MODULE (1, module);
+ var = scm_module_local_variable (module, sym_sys_module_public_interface);
+ if (scm_is_true (var))
+ return SCM_VARIABLE_REF (var);
+ else
+ return SCM_BOOL_F;
+}
+#undef FUNC_NAME
+
/* scm_sym2var
*
* looks up the variable bound to SYM according to PROC. PROC should be
diff --git a/libguile/modules.h b/libguile/modules.h
index afac9f4e4..4f42e1888 100644
--- a/libguile/modules.h
+++ b/libguile/modules.h
@@ -100,6 +100,7 @@ SCM_API void scm_c_export (const char *name, ...);
SCM_API SCM scm_sym2var (SCM sym, SCM thunk, SCM definep);
+SCM_API SCM scm_module_public_interface (SCM module);
SCM_API SCM scm_module_import_interface (SCM module, SCM sym);
SCM_API SCM scm_module_lookup_closure (SCM module);
SCM_API SCM scm_module_transformer (SCM module);