From 4ac41ad82300b5f35862d51ebac7c661f526809a Mon Sep 17 00:00:00 2001 From: amirouche Date: Fri, 1 Sep 2017 21:58:45 +0200 Subject: [PATCH 2/2] add a few ffi procedures inspired from biwascheme --- module/language/js-il/runtime.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/module/language/js-il/runtime.js b/module/language/js-il/runtime.js index 583f21d93..26090055e 100644 --- a/module/language/js-il/runtime.js +++ b/module/language/js-il/runtime.js @@ -926,6 +926,24 @@ function scm_list (self, cont) { }; def_guile0("list", scm_list); +def_guile0("js-eval", function(self, cont, string) { + return cont(eval(string.s)) +}); + +def_guile0("js-ref", function(self, cont, js, attrname) { + return cont(js[attrname.s]); +}); + +def_guile0("js-invoke", function(self, cont, jsobj, methodname) { + var args = Array.prototype.slice.call(arguments).slice(4); + cont(jsobj[methodname.s].apply(jsobj, args)); +}); + +def_guile0("js-call", function(self, cont, jsfunc) { + var args = Array.prototype.slice.call(arguments).slice(3); + cont(jsfunc.apply(undefined, args)); +}); + // Numbers function scm_add(self, cont) { -- 2.11.0