Created
July 18, 2010 19:14
-
-
Save polypus74/480630 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns fxtrial.core | |
(:import javax.script.ScriptEngineManager | |
com.sun.javafx.api.JavaFXScriptEngine)) | |
(def engine (.getEngineByName (ScriptEngineManager.) "javafx")) | |
(defn wrap-fxfn [fxfn] | |
(let [invoke | |
(first (filter #(= (.getName %) "invoke") | |
(.getMethods (class fxfn))))] | |
(fn [& args] | |
(.invoke invoke fxfn (into-array Object args))))) | |
(def code "function(x) { x + x };") | |
(def fxfn (.eval engine code)) | |
((wrap-fxfn fxfn) 8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment