summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-10-25 15:56:09 +0000
committerRich Hickey <richhickey@gmail.com>2008-10-25 15:56:09 +0000
commitb1932d764cbd536c1f6aaeef1277cf862f79395c (patch)
tree45d983a293d2a2fd1ebead26abcab56ddd3aa480 /src
parent382b6ea0067b3058d2c59b4b4a1d57df99ecf17d (diff)
support primitive and array classes in print-method, patch from cemerick
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/boot.clj24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/clj/clojure/boot.clj b/src/clj/clojure/boot.clj
index de1e8715..b7d7ac78 100644
--- a/src/clj/clojure/boot.clj
+++ b/src/clj/clojure/boot.clj
@@ -3610,9 +3610,29 @@
(.append w c))
nil)
+(def primitives-classnames
+ {Float/TYPE "Float/TYPE"
+ Integer/TYPE "Integer/TYPE"
+ Long/TYPE "Long/TYPE"
+ Boolean/TYPE "Boolean/TYPE"
+ Character/TYPE "Character/TYPE"
+ Double/TYPE "Double/TYPE"
+ Byte/TYPE "Byte/TYPE"
+ Short/TYPE "Short/TYPE"})
+
(defmethod print-method Class [#^Class c, #^Writer w]
- (.write w "#=")
- (.write w (.getName c)))
+ (cond
+ (.isPrimitive c) (do
+ (.write w "#=(identity ")
+ (.write w (primitives-classnames c))
+ (.write w ")"))
+ (.isArray c) (do
+ (.write w "#=(java.lang.Class/forName \"")
+ (.write w (.getName c))
+ (.write w "\")"))
+ :else (do
+ (.write w "#=")
+ (.write w (.getName c)))))
(defmethod print-method java.math.BigDecimal [b, #^Writer w]
(.write w (str b))