parent 01320d21
......@@ -205,14 +205,18 @@ NAME can either string or a symbol according to the usual JSS conventions."
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun read-invoke (stream char arg)
(unread-char char stream)
(let ((name (read stream)))
(if (or (find #\. name) (find #\{ name))
(jss-transform-to-field name)
(let ((object-var (gensym))
(args-var (gensym)))
`(lambda (,object-var &rest ,args-var)
(invoke-restargs ,name ,object-var ,args-var ,(eql arg 0)))))))
(if (eql arg 1)
(progn (require 'javaparser)
(read-sharp-java-expression stream))
(progn
(unread-char char stream)
(let ((name (read stream)))
(if (or (find #\. name) (find #\{ name))
(jss-transform-to-field name)
(let ((object-var (gensym))
(args-var (gensym)))
`(lambda (,object-var &rest ,args-var)
(invoke-restargs ,name ,object-var ,args-var ,(eql arg 0)))))))))
(set-dispatch-macro-character #\# #\" 'read-invoke))
(defmacro with-constant-signature (fname-jname-pairs &body body)
......
......@@ -23,8 +23,9 @@
(defun optimized-jss (count)
(loop repeat count do (#"compile" 'regex.Pattern ".*")))
(defun unoptimized-jss (count)
(loop repeat count do (#"compile" 'regex.Pattern ".*")))
(let ((jss::*inhibit-jss-optimization* t))
(defun unoptimized-jss (count)
(loop repeat count do (#"compile" 'regex.Pattern ".*"))))
(defun just-loop (count)
(loop repeat count))
......@@ -44,8 +45,8 @@
(plan 1)
(is-type (let ((just-loop (timeit (just-loop 10000))))
(+ 0.0
(print (/ (- (timeit (optimized-jss 10000)) just-loop)
(- (timeit (unoptimized-jss 10000)) just-loop)))))
(/ (- (timeit (optimized-jss 10000)) just-loop)
(- (timeit (unoptimized-jss 10000)) just-loop))))
'(float 0 0.1))
(plan 2)
......@@ -58,4 +59,38 @@
(finalize)
(plan 1)
(in-package :jss)
(defparameter expanded '(let ((jss::this jss::*object-for-this*))
(jcall "getLoaded"
(jcall "load"
(jcall "make"
(jcall "intercept"
(jcall "method"
(jcall "subclass"
(new '|ByteBuddy|)
(find-java-class '|Object|)
t)
(jstatic "named"
'|ElementMatchers|
"toString"))
(jstatic "value"
'|FixedValue|
"Hello World!")))
(jcall "getClassLoader"
(jcall "getClass" jss::this))))))
(defparameter source '#1"new ByteBuddy().subclass(Object.class,t)
.method(ElementMatchers.named("toString"))
.intercept(FixedValue.value("Hello World!"))
.make()
.load(getClass().getClassLoader())
.getLoaded()" )
(in-package :jss-test)
(is jss::source
jss::expanded)
(finalize)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment