Fix clj (extern call) for js
This commit is contained in:
parent
a072191081
commit
fd77e1ed45
2
src/ludus/draw.cljs
Normal file
2
src/ludus/draw.cljs
Normal file
|
@ -0,0 +1,2 @@
|
|||
(ns ludus.draw)
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
[ludus.show :as show]
|
||||
;[ludus.draw :as d]
|
||||
#?(:cljs [cljs.reader])
|
||||
#?(:cljs [goog.object :as o])
|
||||
))
|
||||
|
||||
;; TODO: make eq, and, or special forms that short-circuit
|
||||
|
@ -234,15 +235,23 @@
|
|||
:cljs cljs.reader/read-string
|
||||
))
|
||||
|
||||
(defn- resolve-str [str]
|
||||
#?(
|
||||
:clj (eval str)
|
||||
:cljs (.bind (o/get js/window str) js/window)
|
||||
))
|
||||
|
||||
(def clj {:name "clj"
|
||||
::data/type ::data/clj
|
||||
:body (fn [& args]
|
||||
(println "Args passed: " args)
|
||||
(let [called (-> args first strpart readstr eval)
|
||||
(let [called (-> args first strpart readstr resolve-str)
|
||||
fn-args (rest args)]
|
||||
(println "Fn: " called)
|
||||
(println "Args: " fn-args)
|
||||
(apply called fn-args)))})
|
||||
(println "Args: " (clj->js fn-args))
|
||||
#?(
|
||||
:clj(apply called fn-args)
|
||||
:cljs (.apply called js/window (clj->js fn-args)))))})
|
||||
|
||||
(def count- {:name "count"
|
||||
::data/type ::data/clj
|
||||
|
|
Loading…
Reference in New Issue
Block a user