From 5058a94ee717d96285da20423324af3478df175d Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 25 Feb 2013 01:38:36 -0500 Subject: Expand the loadable object support. Provide a simple API for loaded objects to interact with GNU make. I still won't guarantee that this API won't change but it's much closer to something that's supported and provides easy-to-use interfaces with a public header file. --- guile.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'guile.c') diff --git a/guile.c b/guile.c index 47a21f9..28fcf39 100644 --- a/guile.c +++ b/guile.c @@ -14,6 +14,8 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "gnumake.h" + #include "makeint.h" #include "debug.h" #include "dep.h" @@ -40,7 +42,7 @@ guile_expand_wrapper (SCM obj) char *res; DB (DB_BASIC, (_("guile: Expanding '%s'\n"), str)); - res = allocated_variable_expand (str); + res = gmk_expand (str); ret = scm_from_locale_string (res); free (str); @@ -49,6 +51,18 @@ guile_expand_wrapper (SCM obj) return ret; } +/* Perform the GNU make eval function. */ +static SCM +guile_eval_wrapper (SCM obj) +{ + char *str = cvt_scm_to_str (obj); + + DB (DB_BASIC, (_("guile: Evaluating '%s'\n"), str)); + gmk_eval (str, 0); + + return SCM_BOOL_F; +} + /* Invoked by scm_c_define_module(), in the context of the GNU make module. */ static void guile_define_module (void *data UNUSED) @@ -59,6 +73,9 @@ guile_define_module (void *data UNUSED) /* Register a subr for GNU make's eval capability. */ scm_c_define_gsubr ("gmk-expand", 1, 0, 0, guile_expand_wrapper); + /* Register a subr for GNU make's eval capability. */ + scm_c_define_gsubr ("gmk-eval", 1, 0, 0, guile_eval_wrapper); + /* Define the rest of the module. */ scm_c_eval_string (GUILE_module_defn); } @@ -87,19 +104,12 @@ internal_guile_eval (void *arg) /* This is the function registered with make */ static char * -func_guile (char *o, char **argv, const char *funcname UNUSED) +func_guile (const char *funcname UNUSED, int argc UNUSED, char **argv) { if (argv[0] && argv[0][0] != '\0') - { - char *str = scm_with_guile (internal_guile_eval, argv[0]); - if (str) - { - o = variable_buffer_output (o, str, strlen (str)); - free (str); - } - } - - return o; + return scm_with_guile (internal_guile_eval, argv[0]); + + return NULL; } /* ----- Public interface ----- */ @@ -113,7 +123,7 @@ guile_gmake_setup (const gmk_floc *flocp UNUSED) scm_with_guile (guile_init, NULL); /* Create a make function "guile". */ - define_new_function (NILF, "guile", 0, 1, 1, func_guile); + gmk_add_function ("guile", func_guile, 0, 1, 1); return 1; } -- cgit v1.2.3