diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-10-25 15:56:09 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-10-25 15:56:09 +0000 |
commit | b1932d764cbd536c1f6aaeef1277cf862f79395c (patch) | |
tree | 45d983a293d2a2fd1ebead26abcab56ddd3aa480 /src | |
parent | 382b6ea0067b3058d2c59b4b4a1d57df99ecf17d (diff) |
support primitive and array classes in print-method, patch from cemerick
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/boot.clj | 24 |
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)) |