Skip to content

Instantly share code, notes, and snippets.

@fogus
Created November 19, 2010 20:45
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 fogus/707137 to your computer and use it in GitHub Desktop.
Save fogus/707137 to your computer and use it in GitHub Desktop.
added proxy as return value for init-proxy and update-proxy
From 0ae5ded4202b1c3ceb1d88b1ff38d653d326458b Mon Sep 17 00:00:00 2001
From: fogus <mefogus@gmail.com>
Date: Fri, 19 Nov 2010 15:39:43 -0500
Subject: [PATCH] added proxy as return value for init-proxy and update-proxy
---
src/clj/clojure/core_proxy.clj | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/clj/clojure/core_proxy.clj b/src/clj/clojure/core_proxy.clj
index 38f4ccc..8fe4517 100644
--- a/src/clj/clojure/core_proxy.clj
+++ b/src/clj/clojure/core_proxy.clj
@@ -276,7 +276,8 @@
sets the proxy's fn map."
{:added "1.0"}
[^IProxy proxy mappings]
- (. proxy (__initClojureFnMappings mappings)))
+ (. proxy (__initClojureFnMappings mappings))
+ proxy)
(defn update-proxy
"Takes a proxy instance and a map of strings (which must
@@ -289,7 +290,8 @@
behavior of an existing instance without changing its identity."
{:added "1.0"}
[^IProxy proxy mappings]
- (. proxy (__updateClojureFnMappings mappings)))
+ (. proxy (__updateClojureFnMappings mappings))
+ proxy)
(defn proxy-mappings
"Takes a proxy instance and returns the proxy's fn map."
--
1.6.6
;; the call to init-proxy is required
(-> (get-proxy-class Object)
construct-proxy
(init-proxy {})
(update-proxy {"toString" (fn [this] "blah")})
str)
;=> "blah"
;; another test without construct-proxy
(-> (proxy [Object] [] (toString [] "foo"))
(update-proxy {"toString" (fn [this] "blah")})
str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment