Created
December 2, 2010 22:39
-
-
Save KirinDave/726235 to your computer and use it in GitHub Desktop.
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
(ns com.banksimple.util.scala-tools | |
(:require [clojure.contrib [string :as str]] | |
[def :as deftools])) | |
(defmacro import-singleton [klass-sym] | |
(let [singleton-str (str klass-sym "$") | |
simple-name (symbol (.toLowerCase (last (str/split #"\." (str klass-sym))))) | |
singleton-sym (symbol singleton-str) | |
mod-field-sym (symbol (str singleton-str "/MODULE$"))] | |
`(do (import ~klass-sym ~singleton-sym) | |
(let [sklass-name# (.getSimpleName ~klass-sym)] | |
(deftools/defvar ~simple-name ~mod-field-sym))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment