summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
Diffstat (limited to 'libguile')
-rw-r--r--libguile/ChangeLog2
-rw-r--r--libguile/modules.c36
-rw-r--r--libguile/modules.h3
3 files changed, 40 insertions, 1 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 00e7cf4c6..a11364aae 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,5 +1,7 @@
2003-03-11 Mikael Djurfeldt <djurfeldt@nada.kth.se>
+ * modules.c (scm_module_import_interface): New function.
+
* goops.c, goops.h (scm_class_accessor_method): Renamed from
scm_class_accessor.
(scm_class_accessor): New class.
diff --git a/libguile/modules.c b/libguile/modules.c
index a0031af9c..46b9e7f88 100644
--- a/libguile/modules.c
+++ b/libguile/modules.c
@@ -413,6 +413,42 @@ scm_current_module_transformer ()
return SCM_BOOL_F;
}
+SCM_DEFINE (scm_module_import_interface, "module-import-interface", 2, 0, 0,
+ (SCM module, SCM sym),
+ "")
+#define FUNC_NAME s_scm_module_import_interface
+{
+#define SCM_BOUND_THING_P(b) (!SCM_FALSEP (b))
+ SCM_VALIDATE_MODULE (SCM_ARG1, module);
+ /* Search the use list */
+ SCM uses = SCM_MODULE_USES (module);
+ while (SCM_CONSP (uses))
+ {
+ SCM interface = SCM_CAR (uses);
+ /* 1. Check module obarray */
+ SCM b = scm_hashq_ref (SCM_MODULE_OBARRAY (interface), sym, SCM_BOOL_F);
+ if (SCM_BOUND_THING_P (b))
+ return interface;
+ {
+ SCM binder = SCM_MODULE_BINDER (interface);
+ if (!SCM_FALSEP (binder))
+ /* 2. Custom binder */
+ {
+ b = scm_call_3 (binder, interface, sym, SCM_BOOL_F);
+ if (SCM_BOUND_THING_P (b))
+ return interface;
+ }
+ }
+ /* 3. Search use list recursively. */
+ interface = scm_module_import_interface (interface, sym);
+ if (!SCM_FALSEP (interface))
+ return interface;
+ uses = SCM_CDR (uses);
+ }
+ 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 db3d789be..b1d7cef12 100644
--- a/libguile/modules.h
+++ b/libguile/modules.h
@@ -3,7 +3,7 @@
#ifndef SCM_MODULES_H
#define SCM_MODULES_H
-/* Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -114,6 +114,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_import_interface (SCM module, SCM sym);
SCM_API SCM scm_module_lookup_closure (SCM module);
SCM_API SCM scm_module_transformer (SCM module);
SCM_API SCM scm_current_module_lookup_closure (void);