Package clojure.lang

Examples of clojure.lang.Var$TBox


            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
    }

    private Object commonArefBySubvec(Long start, Long end) {
        Var var = DiametricService.getFn("clojure.core", "subvec");
        // subvec returns from 'start' to element (- end 1)
        return var.invoke(vector_or_seq, start, end);
    }
View Full Code Here


        // subvec returns from 'start' to element (- end 1)
        return var.invoke(vector_or_seq, start, end);
    }

    private Object commonArefByDropTake(Long start, Long length) {
        Var seq_subvec_fn = null;
        if (DiametricService.fnMap.containsKey("seq-subvec")) {
            seq_subvec_fn = DiametricService.fnMap.get("seq-subvec");
        } else {
            Var var = DiametricService.getFn("clojure.core", "load-string");
            seq_subvec_fn = (Var)var.invoke("(defn seq-subvec [seq start length] (take length (drop start seq)))");
            DiametricService.fnMap.put("seq-subvec", seq_subvec_fn);
        }
        return seq_subvec_fn.invoke(vector_or_seq, start, length);
    }
View Full Code Here

    }

    @JRubyMethod
    public IRubyObject compact(ThreadContext context) {
        try {
            Var var = DiametricService.getFn("clojure.core", "remove");
            Var nil_p = DiametricService.getFn("clojure.core", "nil?");
            LazySeq value = (LazySeq) var.invoke(nil_p, vector_or_seq);
            Iterator itr = value.iterator();
            RubyArray result = context.getRuntime().newArray();
            while (itr.hasNext()) {
                Object obj = itr.next();
View Full Code Here

            other_vector = arg;
        } else {
            return context.getRuntime().getFalse();
        }
        try {
            Var var = DiametricService.getFn("clojure.core", "=");
            if ((Boolean)var.invoke(vector_or_seq, other_vector)) {
                return context.getRuntime().getTrue();
            } else {
                return context.getRuntime().getFalse();
            }
        } catch (Throwable t) {
View Full Code Here

   
    @JRubyMethod(required=1, optional=1)
    public IRubyObject fetch(ThreadContext context, IRubyObject args[], Block block) {
        Long index = (Long)args[0].toJava(Long.class);
        try {
            Var var = DiametricService.getFn("clojure.core", "nth");
            // counting vector size will be costly when the vector is way huge.
            // allows to raise exception for negative or too big index
            Object value = var.invoke(vector_or_seq, index);
            return DiametricUtils.convertJavaToRuby(context, value);
        } catch (Throwable t) {
            if (t instanceof IndexOutOfBoundsException) {
                return retryFetch(context, args, block, index);
            }
View Full Code Here

        if (index > (long)getCount()) return handleError(context, args, block);
        if (index < 0L) index += (long)getCount();
        if (index < 0L) return handleError(context, args, block);

        try {
            Var var = DiametricService.getFn("clojure.core", "nth");
            Object value = var.invoke(vector_or_seq, index);
            return DiametricUtils.convertJavaToRuby(context, value);
        } catch (Throwable t) {
            if (t instanceof IndexOutOfBoundsException) {
                return handleError(context, args, block);
            }
View Full Code Here

    }

    @JRubyMethod(name="include?")
    public IRubyObject include_p(ThreadContext context, IRubyObject arg) {
        try {
            Var include_p_fn = null;
            if (DiametricService.fnMap.containsKey("include?")) {
                include_p_fn = DiametricService.fnMap.get("include?");
            } else {
                Var var = DiametricService.getFn("clojure.core", "load-string");
                include_p_fn = (Var)var.invoke("(defn include? [v array] (some (partial = v) array))");
                DiametricService.fnMap.put("include?", include_p_fn);
            }
            Object java_object = DiametricUtils.convertRubyToJava(context, arg);
            Object result = include_p_fn.invoke(java_object, vector_or_seq);
            if ((result instanceof Boolean) && (Boolean)result) {
View Full Code Here

    }

    @JRubyMethod
    public IRubyObject join(ThreadContext context) {
        try {
            Var var = DiametricService.getFn("clojure.string", "join");
            return context.getRuntime().newString((String)var.invoke(vector_or_seq));
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
    }
View Full Code Here

        if (arg.isNil()) {
            return join(context);
        } else if (arg instanceof RubyString) {
            try {
                String separator = (String)arg.toJava(String.class);
                Var var = DiametricService.getFn("clojure.string", "join");
                return context.getRuntime().newString((String)var.invoke(separator, vector_or_seq));
            } catch (Throwable t) {
                throw context.getRuntime().newRuntimeError(t.getMessage());
            }
        }
        return context.getRuntime().getNil();   
View Full Code Here

    }

    @JRubyMethod
    public IRubyObject last(ThreadContext context) {
        try {
            Var var = DiametricService.getFn("clojure.core", "last");
            return DiametricUtils.convertJavaToRuby(context, var.invoke(vector_or_seq));
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of clojure.lang.Var$TBox

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.