Created
November 19, 2010 20:45
-
-
Save fogus/707137 to your computer and use it in GitHub Desktop.
added proxy as return value for init-proxy and update-proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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