Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djhaskin987/75b2fee0e309f3020eb1 to your computer and use it in GitHub Desktop.
Save djhaskin987/75b2fee0e309f3020eb1 to your computer and use it in GitHub Desktop.
;; Big thanks to Christophe Grand - https://groups.google.com/d/msg/clojure/L1GiqSyQVVg/m-WJogaqU8sJ
(defn scaffold [iface]
(doseq [[iface methods] (->> iface .getMethods
(map #(vector (.getName (.getDeclaringClass %))
(symbol (.getName %))
(count (.getParameterTypes %))))
(group-by first))]
(println (str " " iface))
(doseq [[_ name argcount] methods]
(println
(str " "
(list name (into ['this] (take argcount (repeatedly gensym)))))))))
;;user=> (scaffold clojure.lang.IPersistentMap)
;; clojure.lang.IPersistentMap
;; (assoc [this G__441 G__442])
;; (without [this G__443])
;; (assocEx [this G__444 G__445])
;; java.lang.Iterable
;; (iterator [this])
;; clojure.lang.Associative
;; (containsKey [this G__446])
;; (assoc [this G__447 G__448])
;; (entryAt [this G__449])
;; clojure.lang.IPersistentCollection
;; (count [this])
;; (cons [this G__450])
;; (empty [this])
;; (equiv [this G__451])
;; clojure.lang.Seqable
;; (seq [this])
;; clojure.lang.ILookup
;; (valAt [this G__452 G__453])
;; (valAt [this G__454])
;; clojure.lang.Counted
;; (count [this])
;; nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment