File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1676
1676
[rsym rname fields]
1677
1677
(core/let [fn-name (with-meta (symbol (core/str '-> rsym))
1678
1678
(assoc (meta rsym) :factory :positional ))
1679
+ docstring (core/str " Positional factory function for " rname " ." )
1679
1680
field-values (if (core/-> rsym meta :internal-ctor ) (conj fields nil nil nil ) fields)]
1680
1681
`(defn ~fn-name
1682
+ ~docstring
1681
1683
[~@fields]
1682
1684
(new ~rname ~@field-values))))
1683
1685
1859
1861
(core/defn- build-map-factory [rsym rname fields]
1860
1862
(core/let [fn-name (with-meta (symbol (core/str 'map-> rsym))
1861
1863
(assoc (meta rsym) :factory :map ))
1864
+ docstring (core/str " Factory function for " rname " , taking a map of keywords to field values." )
1862
1865
ms (gensym )
1863
1866
ks (map keyword fields)
1864
1867
getters (map (core/fn [k] `(~k ~ms)) ks)]
1865
- `(defn ~fn-name [~ms]
1868
+ `(defn ~fn-name ~docstring [~ms]
1866
1869
(new ~rname ~@getters nil (not-empty (dissoc ~ms ~@ks)) nil ))))
1867
1870
1868
1871
(core/defmacro defrecord
Original file line number Diff line number Diff line change 1483
1483
(is (= " ##Inf" (pr-str js/Infinity)))
1484
1484
(is (= " ##-Inf" (pr-str js/-Infinity))))
1485
1485
1486
+ (deftype Foo2407 [x y])
1487
+ (defrecord Bar2407 [x y])
1488
+
1489
+ (deftest test-cljs-2407
1490
+ (is (= " Positional factory function for cljs.core-test/Foo2407." (:doc (meta #'->Foo2407))))
1491
+ (is (= " Positional factory function for cljs.core-test/Bar2407." (:doc (meta #'->Bar2407))))
1492
+ (is (= " Factory function for cljs.core-test/Bar2407, taking a map of keywords to field values." (:doc (meta #'map->Bar2407)))))
1493
+
1486
1494
(comment
1487
1495
; ; ObjMap
1488
1496
; ; (let [ks (map (partial str "foo") (range 500))
You can’t perform that action at this time.
0 commit comments