Skip to content

Commit e90d7e0

Browse files
author
dnolen
committed
#object printing for deftype w/o printing implementation, and for Volatile and for Atom
1 parent 34c3b89 commit e90d7e0

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8839,11 +8839,15 @@ reduces them without incurring seq initialization"
88398839
(-pr-writer obj writer opts)
88408840

88418841
:else
8842-
(let [name (.. obj -constructor -name)
8843-
name (if (or (nil? name) (gstring/isEmpty name))
8844-
"Object"
8845-
name)]
8846-
(write-all writer "#object[" name " " (str obj) "]"))))))
8842+
(if (.. obj -constructor -cljs$lang$ctorStr)
8843+
(write-all writer
8844+
"#object[" (.replace (.. obj -constructor -cljs$lang$ctorStr)
8845+
(js/RegExp. "/" "g") ".") "]")
8846+
(let [name (.. obj -constructor -name)
8847+
name (if (or (nil? name) (gstring/isEmpty name))
8848+
"Object"
8849+
name)]
8850+
(write-all writer "#object[" name " " (str obj) "]")))))))
88478851

88488852
(defn- pr-writer
88498853
"Prefer this to pr-seq, because it makes the printing function
@@ -9050,15 +9054,15 @@ reduces them without incurring seq initialization"
90509054

90519055
Atom
90529056
(-pr-writer [a writer opts]
9053-
(-write writer "#<Atom: ")
9054-
(pr-writer (.-state a) writer opts)
9055-
(-write writer ">"))
9057+
(-write writer "#object [cljs.core.Atom ")
9058+
(pr-writer {:val (.-state a)} writer opts)
9059+
(-write writer "]"))
90569060

90579061
Volatile
90589062
(-pr-writer [a writer opts]
9059-
(-write writer "#<Volatile: ")
9060-
(pr-writer (.-state a) writer opts)
9061-
(-write writer ">"))
9063+
(-write writer "#object [cljs.core.Volatile ")
9064+
(pr-writer {:val (.-state a)} writer opts)
9065+
(-write writer "]"))
90629066

90639067
Var
90649068
(-pr-writer [a writer opts]

0 commit comments

Comments
 (0)