(in-package :cl-user) ;; defines a function that creates a function that iterates using the ;; visitor pattern. Name is the name of the function, args has two keywords: ;; CALLER: Initialization form for the think that does the walking ;; INVOKER: Function that is called on the CALLER and the visitor to do the iteration. ;; The visitor java instance is created automatically. ;; Created function needs to have the first argument be a function that will be called for each visit. ;; Arguments to that function are: (caller-java-instance visitor-java-instance &rest arguments-the-visit-function-is-called-with) (defmacro define-owl-visitor (name args keys) (destructuring-bind (&key caller invoker) keys (let ((callername (make-symbol "CALLER")) (visitorname (make-symbol "VISITOR"))) `(defun ,name ,args (let ((,callername ,caller) (,visitorname nil)) (setq ,visitorname (jinterface-safe-implementation (find-java-class 'org.semanticweb.owl.model.OWLObjectVisitorEx) "visit" (lambda(&rest args) (Apply ,(car args) ,callername ,visitorname args) (make-immediate-object nil :ref)))) (,invoker ,callername ,visitorname) )))))