;;; Javascript FFI
-;; Receives the JS function as first argument as a literal string. The
-;; second argument is compiled and should evaluate to a vector of
-;; values to apply to the the function. The result returned. No type
-;; conversion is done here. It is supposed to happen in the
-;; trampoline.
-(define-builtin %js-call (fun args)
- (code fun ".apply(this, " args "))"))
-
(define-compilation %js-vref (var)
(code "js_to_lisp(" var ")"))
;; consing, as well as allow inline declarations.
(fset symbol
(eval `(lambda (&rest ,args)
- (%js-call (%js-vref ,sym-name) (list-to-vector ,args)))))
+ (apply (%js-vref ,sym-name) ,args))))
;; Define it as a symbol macro to access to the
;; Javascript variable literally.
(%define-symbol-macro symbol `(%js-vref ,(string symbol))))))