Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't call `pr-str` from `missing-protocol`. add type string as

property on ctor. remove pr-str calls from deftypes. Fix Subvec
compare bug.
  • Loading branch information...
commit f5ac74e39c304b1db886cfe3feb5a8db274f95b4 1 parent 4b061c0
David Nolen swannodette authored
Showing with 6 additions and 98 deletions.
  1. +2 −2 src/clj/cljs/core.clj
  2. +4 −96 src/cljs/cljs/core.cljs
4 src/clj/cljs/core.clj
View
@@ -681,14 +681,14 @@
`(do
(deftype* ~t ~fields ~pmasks)
(set! (.-cljs$lang$type ~t) true)
- (set! (.-cljs$lang$ctorPrSeq ~t) (fn [this#] (list ~(core/str r))))
+ (set! (.-cljs$lang$ctorStr ~t) ~(core/str r))
(set! (.-cljs$lang$ctorPrWriter ~t) (fn [this# writer# opt#] (-write writer# ~(core/str r))))
(extend-type ~t ~@(dt->et t impls fields true))
~t)
`(do
(deftype* ~t ~fields ~pmasks)
(set! (.-cljs$lang$type ~t) true)
- (set! (.-cljs$lang$ctorPrSeq ~t) (fn [this#] (list ~(core/str r))))
+ (set! (.-cljs$lang$ctorStr ~t) ~(core/str r))
(set! (.-cljs$lang$ctorPrWriter ~t) (fn [this# writer# opts#] (-write writer# ~(core/str r))))
~t))))
100 src/cljs/cljs/core.cljs
View
@@ -90,7 +90,7 @@
(defn missing-protocol [proto obj]
(let [ty (type obj)
ty (if (and ty (.-cljs$lang$type ty))
- (pr-str ty)
+ (.-cljs$lang$ctorStr ty)
(goog/typeOf obj))]
(js/Error.
(.join (array "No protocol method " proto
@@ -632,10 +632,6 @@ reduces them without incurring seq initialization"
[x] (satisfies? IIndexed x))
(deftype IndexedSeq [arr i]
- Object
- (toString [this]
- (pr-str this))
-
ISeqable
(-seq [this] this)
@@ -737,10 +733,6 @@ reduces them without incurring seq initialization"
(declare with-meta)
(deftype RSeq [ci i meta]
- Object
- (toString [this]
- (pr-str this))
-
IMeta
(-meta [coll] meta)
IWithMeta
@@ -1749,10 +1741,6 @@ reduces them without incurring seq initialization"
(deftype List [meta first rest count ^:mutable __hash]
IList
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (List. meta first rest count __hash))
@@ -1799,10 +1787,6 @@ reduces them without incurring seq initialization"
(deftype EmptyList [meta]
IList
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (EmptyList. meta))
@@ -1872,10 +1856,6 @@ reduces them without incurring seq initialization"
(deftype Cons [meta first rest ^:mutable __hash]
IList
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (Cons. meta first rest __hash))
@@ -1988,10 +1968,6 @@ reduces them without incurring seq initialization"
(.-x lazy-seq)))))
(deftype LazySeq [meta realized x ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (LazySeq. meta realized x __hash))
@@ -3061,10 +3037,6 @@ reduces them without incurring seq initialization"
pr-sequential-writer pr-writer chunked-seq)
(deftype PersistentVector [meta cnt shift root tail ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (PersistentVector. meta cnt shift root tail __hash))
@@ -3300,10 +3272,6 @@ reduces them without incurring seq initialization"
(declare build-subvec)
(deftype Subvec [meta v start end ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (build-subvec meta v start end __hash))
@@ -3584,10 +3552,6 @@ reduces them without incurring seq initialization"
;;; PersistentQueue ;;;
(deftype PersistentQueueSeq [meta front rear ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (PersistentQueueSeq. meta front rear __hash))
@@ -3620,10 +3584,6 @@ reduces them without incurring seq initialization"
(-seq [coll] coll))
(deftype PersistentQueue [meta count front rear ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (PersistentQueue. meta count front rear __hash))
@@ -3737,10 +3697,6 @@ reduces them without incurring seq initialization"
new-obj))
(deftype ObjMap [meta keys strobj update-count ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (ObjMap. meta keys strobj update-count __hash))
@@ -3909,10 +3865,6 @@ reduces them without incurring seq initialization"
(declare TransientArrayMap)
(deftype PersistentArrayMap [meta cnt arr ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (PersistentArrayMap. meta cnt arr __hash))
@@ -4609,10 +4561,6 @@ reduces them without incurring seq initialization"
(.inode-assoc! edit shift key2hash key2 val2 added-leaf?)))))))
(deftype NodeSeq [meta nodes i s ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IMeta
(-meta [coll] meta)
@@ -4670,10 +4618,6 @@ reduces them without incurring seq initialization"
(NodeSeq. nil nodes i s nil))))
(deftype ArrayNodeSeq [meta nodes i s ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IMeta
(-meta [coll] meta)
@@ -4723,10 +4667,6 @@ reduces them without incurring seq initialization"
(declare TransientHashMap)
(deftype PersistentHashMap [meta cnt root ^boolean has-nil? nil-val ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (PersistentHashMap. meta cnt root has-nil? nil-val __hash))
@@ -4945,10 +4885,6 @@ reduces them without incurring seq initialization"
stack)))
(deftype PersistentTreeMapSeq [meta stack ^boolean ascending? cnt ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
ISeqable
(-seq [this] this)
@@ -5097,9 +5033,6 @@ reduces them without incurring seq initialization"
(deftype BlackNode [key val left right ^:mutable __hash]
Object
- (toString [this]
- (pr-str this))
-
(add-left [node ins]
(.balance-left ins node))
@@ -5128,9 +5061,6 @@ reduces them without incurring seq initialization"
(kv-reduce [node f init]
(tree-map-kv-reduce node f init))
- (toString [this]
- (pr-str this))
-
IMapEntry
(-key [node] key)
(-val [node] val)
@@ -5205,9 +5135,6 @@ reduces them without incurring seq initialization"
(deftype RedNode [key val left right ^:mutable __hash]
Object
- (toString [this]
- (pr-str this))
-
(add-left [node ins]
(RedNode. key val ins right nil))
@@ -5275,9 +5202,6 @@ reduces them without incurring seq initialization"
(kv-reduce [node f init]
(tree-map-kv-reduce node f init))
- (toString [this]
- (pr-str this))
-
IMapEntry
(-key [node] key)
(-val [node] val)
@@ -5459,9 +5383,6 @@ reduces them without incurring seq initialization"
(deftype PersistentTreeMap [comp tree cnt meta ^:mutable __hash]
Object
- (toString [this]
- (pr-str this))
-
(entry-at [coll k]
(loop [t tree]
(if-not (nil? t)
@@ -5690,10 +5611,6 @@ reduces them without incurring seq initialization"
(declare TransientHashSet)
(deftype PersistentHashSet [meta hash-map ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (PersistentHashSet. meta hash-map __hash))
@@ -5799,10 +5716,6 @@ reduces them without incurring seq initialization"
k)))
(deftype PersistentTreeSet [meta tree-map ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [coll meta] (PersistentTreeSet. meta tree-map __hash))
@@ -6050,10 +5963,6 @@ reduces them without incurring seq initialization"
(if ((mk-bound-fn sc end-test end-key) e) s (next s))))))
(deftype Range [meta start end step ^:mutable __hash]
- Object
- (toString [this]
- (pr-str this))
-
IWithMeta
(-with-meta [rng meta] (Range. meta start end step __hash))
@@ -6581,6 +6490,9 @@ reduces them without incurring seq initialization"
;; IComparable
(extend-protocol IComparable
+ Subvec
+ (-compare [x y] (compare-indexed x y))
+
PersistentVector
(-compare [x y] (compare-indexed x y)))
@@ -7186,10 +7098,6 @@ Maps become Objects. Arbitrary keys are encoded to by key->js."
;; UUID
(deftype UUID [uuid]
- Object
- (toString [this]
- (pr-str this))
-
IEquiv
(-equiv [_ other]
(and (instance? UUID other) (identical? uuid (.-uuid other))))
Please sign in to comment.
Something went wrong with that request. Please try again.