Package clojure.lang

Examples of clojure.lang.IFn$LLOLO


        }
    }

    public void onClose(int status) {
        if (unsafe.compareAndSwapInt(this, closedRanOffset, 0, 1)) {
            IFn f = closeHandler;
            if (f != null) {
                f.invoke(readable(status));
            }
        }
    }
View Full Code Here


            server.tryWrite(key, WsEncode(OPCODE_CLOSE, ByteBuffer.allocate(2)
                    .putShort((short) status).array()));
        } else {
            server.tryWrite(key, false, ByteBuffer.wrap(finalChunkBytes));
        }
        IFn f = closeHandler;
        if (f != null) {
            f.invoke(readable(0)); // server close is 0
        }
        return true;
    }
View Full Code Here

     * Vars named in the Servlet initialization parameters. If an init
     * function was provided, invokes it. */
    @Override
    public void init() throws ServletException {
        ServletConfig config = this.getServletConfig();
        IFn initFn = getVar(config, "init");
        IFn serviceFn = getVar(config, "service");
        IFn destroyFn = getVar(config, "destroy");

        if (serviceFn == null) {
            throw new ServletException("Missing required parameter 'service'");
        }

View Full Code Here

        } catch(Throwable t) {
            throw new ServletException("Failed to load namespace '"
                                       + namespace + "'", t);
        }

        IFn fn = Clojure.var(namespace, name);
        if (fn == null) {
            throw new ServletException("Var '" + varName + "' not found");
        }
        return fn;
    }
View Full Code Here

      } else {
        maybeApply=false;
      }
    }
    if (maybeApply&&nFunc.isConstant()) {
      IFn fn=(IFn) ((Constant<?>)nFunc).getValue();
      if (KissUtils.isPureFn(fn)) {
        // compute result
        Object[] ps=new Object[arity];
        for (int i=0; i<arity; i++) {
          ps[i]=((Constant<?>)nParams[i]).getValue();
        }
        return Constant.create(fn.applyTo(RT.seq(ps)));
      }
    }
    return update(nFunc,nParams);
  }
View Full Code Here

  @Override
  public Environment compute(Environment d, IPersistentMap bindings) {
    d=func.compute(d, bindings);
    Object o=d.getResult();
    if (!(o instanceof IFn)) throw new KissException("Not a function: "+o);
    IFn fn=(IFn)o;
   
    int n=params.length;
    Object[] args=new Object[n];
    for (int i=0; i<n; i++) {
      d=params[i].compute(d, bindings);
      if (d.isExiting()) return d;
      args[i]=d.getResult();
    }
   
    return d.withResult(fn.applyTo(ArraySeq.create(args)));
  }
View Full Code Here

            return null;
        }

        public void generate(Object obj) throws Exception{
            if (this.coercions != null) {
                IFn fn;
                while ((fn = (IFn)coercions.get(this.coercionKey(obj))) != null){
                    obj = fn.invoke(obj);
                }
            }

            if (obj instanceof String) {
                jg.writeString((String) obj);
View Full Code Here

  @Test
  public void testIdentity() {
    Lambda id=Lambda.IDENTITY;
    FunctionType ft=(FunctionType) id.getType();
    assertEquals(Anything.INSTANCE,ft.getReturnType());
    IFn fn=(IFn) id.eval();
    assertEquals(1,fn.invoke(1));
    assertTrue(ft.checkInstance(fn));
  }
View Full Code Here

    }
   
    Expression fn=analyse(first);
    if (KissUtils.isMacro(fn)) {
      // TODO: macro expend with expansion passing?
      IFn macroFn=(IFn) fn.eval(Environment.EMPTY);
      Object expandedForm=macroFn.applyTo(RT.cons(form,RT.cons(PersistentHashMap.EMPTY, form.next())));
      return analyse(expandedForm);
    }
   
    ISeq paramSeq=RT.next(form);
    int paramCount=RT.count(paramSeq);
View Full Code Here

    _params = params;
  }

  @Override
  public void prepare(final Map conf, final Object registrationArgument, final TopologyContext context, final IErrorReporter errorReporter) {
    IFn hof = Utils.loadClojureFn(_fnSpec.get(0), _fnSpec.get(1));
    try {
      IFn preparer = (IFn) hof.applyTo(RT.seq(_params));
      List<Object> args = new ArrayList<Object>() {{
          add(conf);
          add(registrationArgument);
          add(context);
          add(errorReporter);
        }};

      _fn = (IMetricsConsumer) preparer.applyTo(RT.seq(args));

      try {
        _fn.prepare(conf, registrationArgument, context, errorReporter);
      } catch (AbstractMethodError ame) {
View Full Code Here

TOP

Related Classes of clojure.lang.IFn$LLOLO

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.