Preliminary proxy support
This commit is contained in:
parent
6a47a4dc29
commit
fa92537bdf
1 changed files with 18 additions and 0 deletions
18
src/babashka/impl/proxy.clj
Normal file
18
src/babashka/impl/proxy.clj
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
(ns babashka.impl.proxy
|
||||||
|
{:no-doc true}
|
||||||
|
(:require [sci.impl.types]))
|
||||||
|
|
||||||
|
(set! *warn-on-reflection* false)
|
||||||
|
|
||||||
|
(defn method-or-bust [methods k]
|
||||||
|
(or (get methods k)
|
||||||
|
(throw (UnsupportedOperationException. "Method not implemented: " k))))
|
||||||
|
|
||||||
|
(defn proxy-fn [{:keys [:class :methods]}]
|
||||||
|
(case (.getName ^Class class)
|
||||||
|
"clojure.lang.APersistentMap"
|
||||||
|
(proxy [clojure.lang.APersistentMap] []
|
||||||
|
(seq [] ((method-or-bust methods 'seq)))
|
||||||
|
(valAt
|
||||||
|
([k] ((method-or-bust methods 'valAt) k))
|
||||||
|
([k default] ((method-or-bust methods 'valAt) k default))))))
|
||||||
Loading…
Reference in a new issue