stable
This commit is contained in:
parent
2f5d2320bd
commit
8d35ea95f2
2 changed files with 25 additions and 9 deletions
|
|
@ -1,17 +1,30 @@
|
||||||
(ns scittle.makro-plugin
|
(ns scittle.makro-plugin
|
||||||
|
(:require-macros [scittle.makros :refer
|
||||||
|
[add-slash-makro add-c-makro]])
|
||||||
(:require
|
(:require
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
[scittle.core :as scittle]))
|
[scittle.core :as scittle]
|
||||||
|
[scittle.makros :as sm]))
|
||||||
|
|
||||||
(defn add-low-fn [_env _form x y] `(str "_" ~x ~y))
|
(.log js/console (add-slash-makro 1 2))
|
||||||
(defn ^:macro add-low-makro [_env _form x y] (add-low-fn _env _form x y))
|
(.log js/console (add-c-makro 5 6))
|
||||||
|
|
||||||
(def rns (sci/create-ns 'makro-plugin.core nil))
|
(defn add-low-fn [form env x y]
|
||||||
|
`(str "_ form: " ~(str form) " env: " ~(str env) ~x ~y))
|
||||||
|
(defn ^:macro add-low-sci-makro [form env x y] (add-low-fn form env x y))
|
||||||
|
(defn ^:macro add-slash-sci-makro [_form _env x y] (add-slash-makro x y))
|
||||||
|
(defn ^:macro add-c-sci-makro [form env x y] (sm/add-c-fn form env x y))
|
||||||
|
|
||||||
(def makro-plugin-namespace
|
(def rns (sci/create-ns 'scittle.makros nil))
|
||||||
|
|
||||||
|
(def scittle-makros-namespace
|
||||||
{'add-low-fn (sci/copy-var add-low-fn rns)
|
{'add-low-fn (sci/copy-var add-low-fn rns)
|
||||||
'add-low-makro (sci/copy-var add-low-makro rns)})
|
'add-low-sci-makro (sci/copy-var add-low-sci-makro rns)
|
||||||
|
'make-string (sci/copy-var sm/make-string rns)
|
||||||
|
'add-slash-sci-makro (sci/copy-var add-slash-sci-makro rns)
|
||||||
|
'add-c-sci-makro (sci/copy-var add-c-sci-makro rns)
|
||||||
|
})
|
||||||
|
|
||||||
(scittle/register-plugin!
|
(scittle/register-plugin!
|
||||||
::makro-plugin
|
::makro-plugin
|
||||||
{:namespaces {'makro-plugin.core makro-plugin-namespace}})
|
{:namespaces {'scittle.makros scittle-makros-namespace}})
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,13 @@
|
||||||
<script src="./resources/public/js/scittle.js"></script>
|
<script src="./resources/public/js/scittle.js"></script>
|
||||||
<script src="./resources/public/js/scittle.makro-plugin.js"></script>
|
<script src="./resources/public/js/scittle.makro-plugin.js"></script>
|
||||||
<script type="application/x-scittle">
|
<script type="application/x-scittle">
|
||||||
(require '[makro-plugin.core :as m])
|
(require '[scittle.makros :as m])
|
||||||
(defn my-alert []
|
(defn my-alert []
|
||||||
(.log js/console (m/add-low-fn 1 2 5 6))
|
(.log js/console (m/add-low-fn 1 2 5 6))
|
||||||
(.log js/console (m/add-low-makro 7 8)))
|
(.log js/console (m/add-low-sci-makro 7 8))
|
||||||
|
(.log js/console (m/add-slash-sci-makro 1 2))
|
||||||
|
(.log js/console (m/add-c-sci-makro 3 4))
|
||||||
|
)
|
||||||
(set! (.-my_alert js/window) my-alert)
|
(set! (.-my_alert js/window) my-alert)
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue