Advertisement
Guest User

Untitled

a guest
Jun 10th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package com.example.ifidsadminutility;
  2.  
  3. import android.util.Log;
  4. import clojure.lang.IFn;
  5. import clojure.lang.RT;
  6. import clojure.lang.Var;
  7. import clojure.lang.Compiler;
  8. import clojure.java.api.Clojure;
  9. import java.io.StringReader;
  10.  
  11. public class ScriptManager {
  12.     private static ScriptManager instance = null;
  13.    
  14.     public static ScriptManager getInstance() {
  15.            if(instance == null) {
  16.               instance = new ScriptManager();
  17.            }
  18.            return instance;
  19.     }
  20.    
  21.     public void runTest() {    
  22.         // Load the Clojure script -- as a side effect this initializes the runtime.
  23.         String str = "(ns user) (defn foo [a b]   (str a \" \" b))";
  24.  
  25.         //TODO: Load string into the clojure runtime
  26.         //RT.loadResourceScript("foo.clj");
  27.        
  28.         IFn map = Clojure.var("clojure.core", "map");
  29.         IFn inc = Clojure.var("clojure.core", "inc");
  30.         map.invoke(inc, Clojure.read("[1 2 3]"));
  31.        
  32.         // Get a reference to the foo function.
  33.         IFn foo = Clojure.var("user", "foo");
  34.  
  35.         // Call it!
  36.         Object result = foo.invoke("\"Hi\" \"there\"");
  37.         Log.v("ScriptManager", result.toString());
  38.        
  39.        
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement