guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 08/16: Add scm_maybe_resolve_module


From: Andy Wingo
Subject: [Guile-commits] 08/16: Add scm_maybe_resolve_module
Date: Mon, 14 May 2018 10:48:35 -0400 (EDT)

wingo pushed a commit to branch master
in repository guile.

commit 16a996f052f381d915288bc4f39dfc4c21930295
Author: Andy Wingo <address@hidden>
Date:   Mon May 14 10:38:05 2018 +0200

    Add scm_maybe_resolve_module
    
    * libguile/modules.c (scm_maybe_resolve_module): New API function, like
      resolve-module but not ensuring that the module is created.
      (scm_public_variable, scm_private_variable): Adapt to call
      scm_maybe_resolve_module.
    * libguile/modules.h (scm_maybe_resolve_module): Declare new API.
---
 libguile/modules.c | 15 ++++++++++-----
 libguile/modules.h |  3 ++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/libguile/modules.c b/libguile/modules.c
index b469a1a..b5fdbf6 100644
--- a/libguile/modules.c
+++ b/libguile/modules.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 
1998,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,2017 Free 
Software Foundation, Inc.
+/* Copyright (C) 1998,2000-2004,2006-2012,2017-2018 Free Software Foundation, 
Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -177,6 +177,13 @@ scm_resolve_module (SCM name)
 }
 
 SCM
+scm_maybe_resolve_module (SCM name)
+{
+  return scm_call_3 (SCM_VARIABLE_REF (resolve_module_var), name,
+                     k_ensure, SCM_BOOL_F);
+}
+
+SCM
 scm_c_define_module (const char *name,
                     void (*init)(void *), void *data)
 {
@@ -633,8 +640,7 @@ scm_public_variable (SCM module_name, SCM name)
 {
   SCM mod, iface;
   
-  mod = scm_call_3 (scm_variable_ref (resolve_module_var), module_name,
-                    k_ensure, SCM_BOOL_F);
+  mod = scm_maybe_resolve_module (module_name);
 
   if (scm_is_false (mod))
     scm_misc_error ("public-lookup", "Module named ~s does not exist",
@@ -654,8 +660,7 @@ scm_private_variable (SCM module_name, SCM name)
 {
   SCM mod;
   
-  mod = scm_call_3 (scm_variable_ref (resolve_module_var), module_name,
-                    k_ensure, SCM_BOOL_F);
+  mod = scm_maybe_resolve_module (module_name);
 
   if (scm_is_false (mod))
     scm_misc_error ("private-lookup", "Module named ~s does not exist",
diff --git a/libguile/modules.h b/libguile/modules.h
index 28df6c6..207ec44 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, 2003, 2006, 2007, 2008, 2011, 2012 
Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2011, 2012, 
2018 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -108,6 +108,7 @@ SCM_API SCM scm_c_private_ref (const char *module_name, 
const char *name);
 
 SCM_API SCM scm_c_resolve_module (const char *name);
 SCM_API SCM scm_resolve_module (SCM name);
+SCM_API SCM scm_maybe_resolve_module (SCM name);
 SCM_API SCM scm_c_define_module (const char *name,
                                 void (*init)(void *), void *data);
 SCM_API void scm_c_use_module (const char *name);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]