Package clojure.lang

Examples of clojure.lang.Var


        }
    }

    IRubyObject to_s(ThreadContext context, Object target) {
        try {
            Var to_s_fn = null;
            if (DiametricService.fnMap.containsKey("to-s")) {
                to_s_fn = DiametricService.fnMap.get("to-s");
            } else {
                Var var = DiametricService.getFn("clojure.core", "load-string");
                String fn = "(defn to-s [coll] (str (reduce str \"[\" (interpose \", \" coll)) \"]\"))";
                to_s_fn = (Var)var.invoke(fn);
                DiametricService.fnMap.put("to-s", to_s_fn);
            }
            return context.getRuntime().newString((String)to_s_fn.invoke(target));
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
View Full Code Here


        throw context.getRuntime().newArgumentError("Argument should be Fixnum or dbid object");
    }

    private IRubyObject createEntity(ThreadContext context, Long entityId) {
        try {
            Var entity_fn = DiametricService.getFn("datomic.api", "entity");
            Entity entity = (Entity) entity_fn.invoke(database, entityId);
            RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Entity");
            DiametricEntity diametric_entity = (DiametricEntity)clazz.allocate();
            diametric_entity.init(entity);
            return diametric_entity;
        } catch (Throwable t) {
View Full Code Here

        }
    }

    private IRubyObject createFunction(ThreadContext context, RubySymbol arg) {
        try {
            Var keyword_fn = DiametricService.getFn("clojure.core", "keyword");
            Keyword entityKey = (Keyword) keyword_fn.invoke(arg.toString());
            Var entity_fn = DiametricService.getFn("datomic.api", "entity");
            Entity entity = (Entity) entity_fn.invoke(database, entityKey);
            datomic.function.Function function = (Function) entity.get(DiametricService.keywords.get("db/fn"));
            RubyClass clazz = (RubyClass)context.getRuntime().getClassFromPath("Diametric::Persistence::Function");
            DiametricFunction diametric_function = (DiametricFunction)clazz.allocate();
            diametric_function.init(function);
            return diametric_function;
View Full Code Here

      final Bundle bundle) {
    final String ns = (String) bundle.getHeaders().get(
        "Clojure-ActivatorNamespace");
    if (ns != null) {
      final String callbackFunction = callbackFunctionName(callback, ns);
      final Var var = RT.var(ns, callbackFunction);
            if (var.isBound()) {
        try {
          ClojureOSGi.withBundle(bundle, new RunnableWithException() {
            public Object run() throws Exception {
              if (log != null)
                log.log(LogService.LOG_DEBUG,
                    String.format(
                        "invoking function %s/%s for bundle: %s",
                        ns, callbackFunction, bundle));

              var.invoke(bundle.getBundleContext());
             
              return null;
            }
          });
View Full Code Here

    private final static Symbol AGENT_NS_NAME = Symbol.create("jvm.agent");
    private final static Namespace AGENT_NS = Namespace.findOrCreate(AGENT_NS_NAME);
   
    public static void main(InetAddress host, int port, Instrumentation inst)
  throws Exception {
  final Var instv = Var.intern(AGENT_NS, Symbol.create("instrumentation"));
  instv.bindRoot(inst);
  REQUIRE.invoke(REPL_NS);
  REPL.invoke(port, 0, host);
    }
View Full Code Here

    return Anything.INSTANCE;
  }
 
  @Override
  public boolean isMacro() {
    Var v=RT.var(sym.getNamespace(),sym.getName());
    return KissUtils.isTruthy(v.meta().valAt(Keywords.MACRO));
  }
View Full Code Here

  }

  @Override
  public Environment compute(Environment e, IPersistentMap bindings) {
    try {
      Var v=RT.var(sym.getNamespace(),sym.getName());
      if (v!=null) return e.withResult(v.deref());
    } catch (Throwable t) {
      String err="Error trying to lookp var "+sym+" ";
      err+=" with Environment "+e.toString();
      throw new KissException(err,t);
    }
View Full Code Here

    public javax.swing.JEditorPane _replEditorPane;
    public void createReplEditorPane()
    {
        try {
            Var createReplEditorPaneFn =
                    RT.var("org.enclojure.ide.repl.repl-panel"
                            , "create-repl-editor-pane");
            _replEditorPane = (JEditorPane) createReplEditorPaneFn.invoke(this);
        } catch (Exception ex) {
            Logger.getLogger(ReplPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
       
        //??_replEditorPane.setInheritsPopupMenu(true);
View Full Code Here

     */

    public static synchronized ReplTopComponent getDefault() {
        if (instance == null) {
            try {
                Var getIdeReplFn = RT.var("org.enclojure.ide.nb.editor.repl-win", "create-ide-repl");
                return (ReplTopComponent)getIdeReplFn.invoke(IDE_REPL);
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }
        return instance;
View Full Code Here

   
    public synchronized void startREPLServer() {
      if (ackREPLServer == null) {
          try {
            // TODO use ClojureOSGi.withBundle instead
            Var startServer = BundleUtils.requireAndGetVar(getBundle().getSymbolicName(), "clojure.tools.nrepl.server/start-server");
            Object defaultHandler = BundleUtils.requireAndGetVar(
                    getBundle().getSymbolicName(),
                    "clojure.tools.nrepl.server/default-handler").invoke();
            Object handler = BundleUtils.requireAndGetVar(
                    getBundle().getSymbolicName(),
                    "clojure.tools.nrepl.ack/handle-ack").invoke(defaultHandler);
              ackREPLServer = (ServerSocket)((Map)startServer.invoke(Keyword.intern("handler"), handler)).get(Keyword.intern("server-socket"));
              CCWPlugin.log("Started ccw nREPL server: nrepl://127.0.0.1:" + ackREPLServer.getLocalPort());
          } catch (Exception e) {
              CCWPlugin.logError("Could not start plugin-hosted REPL server", e);
              throw new RuntimeException("Could not start plugin-hosted REPL server", e);
          }
View Full Code Here

TOP

Related Classes of clojure.lang.Var

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.