Created
          February 20, 2013 13:38 
        
      - 
      
- 
        Save HairyFotr/4995607 to your computer and use it in GitHub Desktop. 
    Scala Clojure interop wrapper
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | class ClojureWrap(ns: String, objName: String) { | |
| import clojure.lang.{RT,Var} | |
| import scala.collection.mutable.HashMap | |
| RT.loadResourceScript(objName+".clj") | |
| val obj = ns+"."+objName | |
| val funcs = new HashMap[String, Var] | |
| def /(func: String, a: Any): Object = | |
| funcs.getOrElseUpdate(func, RT.`var`(obj, func)).invoke(a.asInstanceOf[Object]) | |
| def /(func: String, a: Any, b: Any): Object = | |
| funcs.getOrElseUpdate(func, RT.`var`(obj, func)).invoke(a.asInstanceOf[Object], b.asInstanceOf[Object]) | |
| def /(func: String, a: Any, b: Any, c: Any): Object = | |
| funcs.getOrElseUpdate(func, RT.`var`(obj, func)).invoke(a.asInstanceOf[Object], b.asInstanceOf[Object], c.asInstanceOf[Object]) | |
| def /(func: String, a: Any, b: Any, c: Any, d: Any): Object = | |
| funcs.getOrElseUpdate(func, RT.`var`(obj, func)).invoke(a.asInstanceOf[Object], b.asInstanceOf[Object], c.asInstanceOf[Object], d.asInstanceOf[Object]) | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment