Permalink
Browse files

* src/clj/cljs/core.clj: remove hasOwnProperty test from satisfies? R…

…elated changes so CLJS ctors are still printable.
  • Loading branch information...
1 parent 1be0a12 commit d0bcfd507e9d37d8a2639c749f963a701e675481 David Nolen committed May 3, 2012
Showing with 25 additions and 14 deletions.
  1. +9 −7 src/clj/cljs/core.clj
  2. +16 −7 src/cljs/cljs/core.cljs
View
@@ -336,12 +336,14 @@
(if (seq impls)
`(do
(deftype* ~t ~fields)
- (set! (.-cljs$core$IPrintable$_pr_seq ~t) (fn [this#] (list ~(core/str r))))
+ (set! (.-cljs$lang$type ~t) true)
+ (set! (.-cljs$lang$ctorPrSeq ~t) (fn [this#] (list ~(core/str r))))
(extend-type ~t ~@(dt->et impls))
~t)
`(do
(deftype* ~t ~fields)
- (set! (.-cljs$core$IPrintable$_pr_seq ~t) (fn [this#] (list ~(core/str r))))
+ (set! (.-cljs$lang$type ~t) true)
+ (set! (.-cljs$lang$ctorPrSeq ~t) (fn [this#] (list ~(core/str r))))
~t))))
(defn- emit-defrecord
@@ -449,7 +451,8 @@
(let [r (:name (cljs.compiler/resolve-var (dissoc &env :locals) rsym))]
`(let []
~(emit-defrecord rsym r fields impls)
- (set! (.-cljs$core$IPrintable$_pr_seq ~r) (fn [this#] (list ~(core/str r))))
+ (set! (.-cljs$lang$type ~r) true)
+ (set! (.-cljs$lang$ctorPrSeq ~r) (fn [this#] (list ~(core/str r))))
~(build-positional-factory rsym r fields)
~(build-map-factory rsym r fields)
~r)))
@@ -492,10 +495,9 @@
xsym (gensym)]
`(let [~xsym ~x]
(if (and (coercive-not= ~xsym nil)
- ~(bool-expr `(. ~xsym ~(symbol (core/str "-" prefix)))) ;; Need prop lookup here
- (coercive-not (. ~xsym (~'hasOwnProperty ~prefix))))
- true
- (cljs.core/type_satisfies_ ~psym ~xsym)))))
+ ~(bool-expr `(. ~xsym ~(symbol (core/str "-" prefix)))))
+ true
+ (cljs.core/type_satisfies_ ~psym ~xsym)))))
(defmacro lazy-seq [& body]
`(new cljs.core.LazySeq nil false (fn [] ~@body)))
View
@@ -42,10 +42,13 @@
(defn type_satisfies_
"Internal - do not use!"
[p x]
- (or
- (aget p (goog.typeOf x))
- (aget p "_")
- false))
+ (cond
+ ;; check that x isn't a CLJS ctor
+ (and (coercive-not= x nil)
+ ^boolean (.-cljs$lang$type x)) false
+ (aget p (goog.typeOf x)) true
+ (aget p "_") true
+ :else false))
(defn is_proto_
[x]
@@ -5551,9 +5554,15 @@ reduces them without incurring seq initialization"
(satisfies? IMeta obj)
(meta obj))
(concat ["^"] (pr-seq (meta obj) opts) [" "]))
- (if (satisfies? IPrintable obj)
- (-pr-seq obj opts)
- (list "#<" (str obj) ">")))))
+ (cond
+ (satisfies? IPrintable obj) (-pr-seq obj opts)
+
+ ;; handle CLJS ctors
+ (and (coercive-not= obj nil)
+ ^boolean (.-cljs$lang$type obj))
+ (.cljs$lang$ctorPrSeq obj obj)
+
+ :else (list "#<" (str obj) ">")))))
(defn- pr-sb [objs opts]
(let [first-obj (first objs)

0 comments on commit d0bcfd5

Please sign in to comment.