1 | (in-package :jss) |
---|
2 | |
---|
3 | (defvar *inhibit-jss-optimization* nil) |
---|
4 | |
---|
5 | ;; https://mailman.common-lisp.net/pipermail/armedbear-devel/2016-October/003726.html |
---|
6 | |
---|
7 | (precompiler::define-function-position-lambda-transform jss::invoke-restargs (arglist form args) |
---|
8 | (declare (ignore arglist)) |
---|
9 | (unless *inhibit-jss-optimization* |
---|
10 | (precompiler::precompile-function-call |
---|
11 | `(jss::invoke-restargs-macro |
---|
12 | ,(second form) |
---|
13 | ,(car args) (list ,@(cdr args)) ,(fifth form))))) |
---|
14 | |
---|
15 | (defmacro invoke-restargs-macro ( method object args &optional (raw? nil)) |
---|
16 | (assert (eq (car args) 'list)) |
---|
17 | (setq args (cdr args)) |
---|
18 | (if (and (consp object) (eq (car object) 'quote)) |
---|
19 | (let ((object (eval object))) |
---|
20 | (let* ((object-as-class |
---|
21 | (or (ignore-errors (let ((*muffle-warnings* t)) (find-java-class object))) |
---|
22 | `(find-java-class ',object)))) |
---|
23 | (if raw? |
---|
24 | `(jstatic-raw ,method ,object-as-class ,@args) |
---|
25 | `(jstatic ,method ,object-as-class ,@args)))) |
---|
26 | (let ((objectvar (make-symbol "INVOKE-RESTARGS-ARG1"))) |
---|
27 | (if raw? |
---|
28 | `(let ((,objectvar ,object)) |
---|
29 | (if (symbolp ,objectvar) |
---|
30 | (jstatic-raw ,method (find-java-class ,objectvar) ,@args) |
---|
31 | (jcall-raw ,method ,objectvar ,@args))) |
---|
32 | `(let ((,objectvar ,object)) |
---|
33 | (if (symbolp ,objectvar) |
---|
34 | (jstatic ,method (find-java-class ,objectvar) ,@args) |
---|
35 | (jcall ,method ,objectvar ,@args))))))) |
---|
36 | |
---|
37 | |
---|
38 | |
---|