Skip to content

Commit

Permalink
adding a secutiry guard on cons->vec, changing getvar to use the getS…
Browse files Browse the repository at this point in the history
…ymbolValue method
  • Loading branch information
lsevero committed Apr 27, 2021
1 parent f4a322d commit 6e04f1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject abclj "0.1.5"
(defproject abclj "0.1.6"
:description "Armed Bear Clojure, dead easy Common Lisp interop"
:url "https://www.github.com/lsevero/abclj"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down
20 changes: 10 additions & 10 deletions src/abclj/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@

(extend-protocol GetVar
clojure.lang.Symbol (getvar [sym]
(.symbolValue (cl-symbol sym)))
(.getSymbolValue (cl-symbol sym)))
Symbol (getvar [sym]
(.symbolValue sym)))
(.getSymbolValue sym)))

(extend-protocol SetFunction
clojure.lang.Symbol (setfunction [sym func]
Expand Down Expand Up @@ -462,13 +462,6 @@
{:pre [(is (cl-obj? obj))]}
(.getBooleanValue obj))

(defn cons->vec
"Converts a CL cons/list to a clojure vector.
Only works for nil terminated lists, not dotted ones"
[^Cons obj]
{:pre [(is (instance? Cons obj))]}
(-> obj .copyToArray vec))

(defn dotted-pair?
"Check if cdr of obj is not nil"
[^Cons obj]
Expand All @@ -480,7 +473,14 @@
"Go to the last Cons of Cons and checks if .-cdr is nil"
[^Cons obj]
{:pre [(is (instance? Cons obj))]}
(->> obj (funcall cl-last) dotted-pair?)))
(not (->> obj (funcall cl-last) dotted-pair?))))

(defn cons->vec
"Converts a CL cons/list to a clojure vector.
Only works for nil terminated lists, not dotted ones"
[^Cons obj]
{:pre [(is (instance? Cons obj)) (is (not (dotted-list? obj)))]}
(-> obj .copyToArray vec))

(defn declojurify [coll]
(letfn [(remove-ns [node]
Expand Down

0 comments on commit 6e04f1a

Please sign in to comment.