Function: js--js-funcall

js--js-funcall is a byte-compiled function defined in js.el.gz.

Signature

(js--js-funcall FUNCTION &rest ARGUMENTS)

Documentation

Call the Mozilla function FUNCTION with arguments ARGUMENTS.

If function is a string, look it up as a property on the global object and use the global object for this. If FUNCTION is a list with one element, use that element as the function with the global object for this, except that if that single element is a string, look it up on the global object. If FUNCTION is a list with more than one argument, use the list up to the last value as a property descriptor and the last argument as a function.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--js-funcall (function &rest arguments)
  "Call the Mozilla function FUNCTION with arguments ARGUMENTS.
If function is a string, look it up as a property on the global
object and use the global object for `this'.
If FUNCTION is a list with one element, use that element as the
function with the global object for `this', except that if that
single element is a string, look it up on the global object.
If FUNCTION is a list with more than one argument, use the list
up to the last value as a property descriptor and the last
argument as a function."

  (with-js
   (let ((argstr (js--js-encode-value
                  (cons function arguments))))

     (with-current-buffer inferior-moz-buffer
       ;; Actual funcall
       (when js--js-array-as-list
         (insert "*"))
       (insert argstr)
       (comint-send-input nil t)
       (js--wait-for-matching-output
        (inferior-moz-process) "EVAL>"
        js-js-timeout)
       (goto-char comint-last-input-end)

       ;; Read the result
       (let* ((json-array-type 'list)
              (result (prog1 (json-read)
                        (goto-char (point-max)))))
         (js--js-decode-retval result))))))