Skip to content

Instantly share code, notes, and snippets.

@polypus74
Created July 18, 2010 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polypus74/480630 to your computer and use it in GitHub Desktop.
Save polypus74/480630 to your computer and use it in GitHub Desktop.
(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