summaryrefslogtreecommitdiff
path: root/guile.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-02-25 01:38:36 -0500
committerPaul Smith <psmith@gnu.org>2013-02-25 01:38:36 -0500
commit5058a94ee717d96285da20423324af3478df175d (patch)
treefa24d78c8f51c77371464d6c03b3aaf886c8f86a /guile.c
parent4baf9ab4564447355b5748d1375959e817771d17 (diff)
downloadgunmake-5058a94ee717d96285da20423324af3478df175d.tar.gz
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.
Diffstat (limited to 'guile.c')
-rw-r--r--guile.c36
1 files changed, 23 insertions, 13 deletions
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 <http://www.gnu.org/licenses/>. */
+#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;
}