Skip to content

Commit

Permalink
dirty work to support metadata in defn; alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Aug 7, 2020
1 parent 0c1ba91 commit 5214d07
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ compiles to:
### API Usage [![Clojars Project](https://img.shields.io/clojars/v/cirru/sepal.svg)](https://clojars.org/cirru/sepal)

```edn
[cirru/sepal "0.2.8"]
[cirru/sepal "0.2.9-a1"]
```

```clojure
Expand Down
2 changes: 2 additions & 0 deletions data/compiled/def.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

(defn f2 ([a b] (+ a b)) ([a b c] (+ a b c)))

(defn ^:dev/after-load f3 [])

(defn- f1 [x] (+ x 1))

(println :key "string" "c" "\n")
1 change: 1 addition & 0 deletions data/examples/def.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"f2"
[["a" "b"] ["+" "a" "b"]]
[["a" "b" "c"] ["+" "a" "b" "c"]]]
["defn" "^:dev/after-load" "f3" []]
["defn-" "f1" ["x"] ["+" "x" "1"]]
["println" ":key" "|string" "\\c" "\\newline"]]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sepal.clj",
"version": "0.2.8",
"version": "0.2.9-a1",
"main": "index.js",
"repository": "git@github.com:Cirru/sepal.clj.git",
"author": "jiyinyiyong <jiyinyiyong@gmail.com>",
Expand All @@ -11,6 +11,6 @@
"test": "yarn compile && node target/test.js"
},
"devDependencies": {
"shadow-cljs": "^2.10.17"
"shadow-cljs": "^2.10.19"
}
}
14 changes: 11 additions & 3 deletions polyfill/cirru_sepal/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
(defn transform-apply [xs]
(map transform-x xs))

(defn transform-defn-meta [tag func params & body]
(assert (string? func) "[Sepal] function name should be a symbol!")
(assert (coll? params) "[Sepal] params should be a sequence!")
`(~'defn ~(symbol tag) ~(symbol func) [~@(map transform-x params)] ~@(map transform-x body)))

(defn transform-defn [func params & body]
(assert (string? func) "[Sepal] function name should be a symbol!")
(assert (coll? params) "[Sepal] params should be a sequence!")
`(~'defn ~(symbol func) [~@(map transform-x params)] ~@(map transform-x body)))
(if (string/starts-with? func "^")
(apply transform-defn-meta func params body)
(do
(assert (string? func) "[Sepal] function name should be a symbol!")
(assert (coll? params) "[Sepal] params should be a sequence!")
`(~'defn ~(symbol func) [~@(map transform-x params)] ~@(map transform-x body)))))

(defn transform-defn$ [func & body]
(assert (string? func) "[Sepal] function name should be a symbol!")
Expand Down
2 changes: 1 addition & 1 deletion release.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:version "0.2.8",
{:version "0.2.9-a1",
:group-id "cirru",
:artifact-id "sepal",
:skip-tag true,
Expand Down
64 changes: 32 additions & 32 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5214d07

Please sign in to comment.