mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/app-utils/guile-util.c
(gnc_depend): deleted. (gnc_scm_lookup): new cross-guile function -- disabled until we can test it. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5599 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
21f756864c
commit
de5f036d0a
@ -30,6 +30,7 @@
|
|||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
#include <g-wrap-runtime-guile.h>
|
#include <g-wrap-runtime-guile.h>
|
||||||
|
#include <libguile/version.h>
|
||||||
|
|
||||||
/* This static indicates the debugging module this .o belongs to. */
|
/* This static indicates the debugging module this .o belongs to. */
|
||||||
static short module = MOD_GUILE;
|
static short module = MOD_GUILE;
|
||||||
@ -292,34 +293,66 @@ gnc_guile_call1_to_vector(SCM func, SCM arg)
|
|||||||
|
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* gnc_depend *
|
gnc_scm_lookup
|
||||||
* ensure the given scm file has been loaded, or return FALSE *
|
|
||||||
* if it cannot be loaded for any reason. *
|
returns the SCM binding associated with the given symbol function,
|
||||||
* *
|
or SCM_UNDEFINED if it couldn't be retrieved.
|
||||||
* Args: scm_file - the file to load if it hasn't been already *
|
|
||||||
* Returns: true if the file has been loaded, false otherwise *
|
Don't use this to get hold of symbols that are considered private
|
||||||
|
to a given module unless the C code you're writing is considered
|
||||||
|
part of that module.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
|
||||||
|
module - where to lookup the symbol, something like "ice-9 debug"
|
||||||
|
symbol - what to look up.
|
||||||
|
|
||||||
|
Returns: value bound to the symbol, if any.
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
gboolean
|
|
||||||
gnc_depend(const char *scm_file)
|
#if 0
|
||||||
|
|
||||||
|
************ NOT TESTED YET **************
|
||||||
|
|
||||||
|
SCM
|
||||||
|
gnc_scm_lookup(const char *module, const char *symbol)
|
||||||
{
|
{
|
||||||
static SCM depend_func = SCM_UNDEFINED;
|
#if defined(SCM_GUILE_MAJOR_VERSION) && \
|
||||||
SCM arg;
|
(SCM_GUILE_MAJOR_VERSION > 0) && (SCM_GUILE_MINOR_VERSION > 4)
|
||||||
|
|
||||||
if (scm_file == NULL)
|
SCM scm_module = scm_c_resolve_module(module);
|
||||||
return FALSE;
|
SCM value = scm_c_module_lookup(scm_module, symbol);
|
||||||
|
return value;
|
||||||
|
#else
|
||||||
|
|
||||||
if (depend_func == SCM_UNDEFINED)
|
gchar *in_guard_str;
|
||||||
depend_func = gh_eval_str("gnc:depend");
|
gchar *thunk_str;
|
||||||
|
SCM in_guard;
|
||||||
|
SCM thunk;
|
||||||
|
SCM out_guard;
|
||||||
|
SCM result;
|
||||||
|
|
||||||
if (!gh_procedure_p(depend_func))
|
in_guard_str =
|
||||||
return FALSE;
|
g_strdup_printf("(lambda () (set-current-module (resolve-module (%s))))",
|
||||||
|
module);
|
||||||
|
|
||||||
/* FIXME: when we drop support older guiles, drop the (char *) coercion. */
|
thunk_str = g_strdup_printf("(lambda () (eval '%s))", symbol);
|
||||||
arg = gh_str02scm((char *) scm_file);
|
|
||||||
|
|
||||||
return gh_scm2bool(gh_call1(depend_func, arg));
|
in_guard = gh_eval_str(in_guard_str);
|
||||||
|
thunk = gh_eval_str(thunk_str);
|
||||||
|
out_guard = gh_eval_str("(let ((cm (current-module)))
|
||||||
|
(lambda () (set-current-module cm)))");
|
||||||
|
|
||||||
|
result = scm_dynamic_wind(in_guard, thunk, out_guard);
|
||||||
|
|
||||||
|
g_free(in_guard_str);
|
||||||
|
g_free(thunk_str);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* gnc_copy_split *
|
* gnc_copy_split *
|
||||||
|
Loading…
Reference in New Issue
Block a user