Refactor JAVAPARSER dependencies out of JSS

JAVAPARSER needs ABCL-ASDF to load its Maven artifact, but ABCL-ASDF
needs JSS.  Therefore we refactor these dependencies into the ASDF
infrastructure rather than dealing with CL:REQUIRE, which isn't going
to work anyways unless there is another mechanism to load Maven
artifacts.

The JAVAPARSER system is not working due to dependency on the missing
symbols CL-USER::REPLACE-ALL and CL-USER::TREE-REPLACE, but that was
the case before this patch as Alan mistakenly didn't include it in his
submitted patch series.
parent 2cf30e6f
......@@ -205,18 +205,14 @@ 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)
(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)))))))))
(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)
......
(defsystem javaparser-tests
:defsystem-depends-on (prove-asdf)
:depends-on (javaparser
prove)
:components ((:module tests
:pathname "t"
:components ((:test-file "javaparser"))))
:perform (asdf:test-op (op c)
(uiop:symbol-call :prove-asdf 'run-test-system c)))
(asdf:defsystem :javaparser
(defsystem javaparser
:description "https://github.com/javaparser/javaparser"
:serial t
:components ((:mvn "com.github.javaparser/javaparser-core/3.0.1")
(:file "javaparser")
(:file "read-sharp-quote-expression")))
:defsystem-depends-on (abcl-asdf)
:components
((:module jar
:components ((:mvn "com.github.javaparser/javaparser-core/3.0.1")))
(:module source :depends-on (jar)
:pathname ""
:serial t
:components ((:file "javaparser")
(:file "read-sharp-quote-expression"))))
:perform (asdf:test-op (op c)
(asdf:test-system :javaparser-tests)))
......@@ -62,5 +62,22 @@
(let ((symbol (intern (#"getIdentifier" node))))
symbol))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun read-invoke/javaparser (stream char arg)
(if (eql arg 1)
(if (ignore-errors (jclass "com.github.javaparser.ParseStart")) ;; chosen randomly, TODO memoize
(read-sharp-java-expression stream)
;; Deal with possiblity of not loading jar
(error "Cannot load javaparser code needed for the #1 macro"))
(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/javaparser))
......@@ -5,7 +5,7 @@
:depends-on (jss
prove)
:components ((:module tests
:pathname ""
:pathname "t"
:components ((:test-file "jss-tests"))))
:perform (asdf:test-op (op c)
(uiop:symbol-call :prove-asdf 'run-test-system c)))
(in-package :cl-user)
#+(or) ;;
(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)
(prove:plan 1)
(proveis jss::source
jss::expanded)
(prove:finalize)
......@@ -59,38 +59,3 @@
(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