Package clojure.lang

Examples of clojure.lang.Var.invoke()


    }

    IRubyObject empty_p(ThreadContext context, Object target) {
        try {
            Var var = DiametricService.getFn("clojure.core", "empty?");
            if ((Boolean)var.invoke(target)) {
                return context.getRuntime().getTrue();
            } else {
                return context.getRuntime().getFalse();
            }
        } catch (Throwable t) {
View Full Code Here


            Var drop_or_take_fn = null;
            if (DiametricService.fnMap.containsKey("drop-or-take")) {
                drop_or_take_fn = DiametricService.fnMap.get("drop-or-take");
            } else {
                Var var = DiametricService.getFn("clojure.core", "load-string");
                drop_or_take_fn = (Var)var.invoke("(defn drop-or-take [n target] (apply vector (drop n target)))");
                DiametricService.fnMap.put("drop-or-take", drop_or_take_fn);
            }
            PersistentVector value = (PersistentVector)drop_or_take_fn.invoke(n, target);
            RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Collection");
            DiametricCollection ruby_collection = (DiametricCollection)clazz.allocate();
View Full Code Here

    }

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

            Var first_n_fn = null;
            if (DiametricService.fnMap.containsKey("first-n")) {
                first_n_fn = DiametricService.fnMap.get("first-n");
            } else {
                Var var = DiametricService.getFn("clojure.core", "load-string");
                first_n_fn = (Var)var.invoke("(defn first-n [n target] (apply vector (take n target)))");
                DiametricService.fnMap.put("first-n", first_n_fn);
            }
            PersistentVector value = (PersistentVector)first_n_fn.invoke(n, target);
            RubyClass clazz = (RubyClass) context.getRuntime().getClassFromPath("Diametric::Persistence::Collection");
            DiametricCollection ruby_collection = (DiametricCollection)clazz.allocate();
View Full Code Here

    }
   
    IRubyObject hash(ThreadContext context, Object target) {
        try {
            Var var = DiametricService.getFn("clojure.core", "hash");
            Integer hash_value = (Integer)var.invoke(target);
            return context.getRuntime().newFixnum(hash_value);
        } catch (Throwable t) {
            throw context.getRuntime().newRuntimeError(t.getMessage());
        }
    }
View Full Code Here

            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

    }

    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();
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

                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

TOP
Copyright © 2018 www.massapi.com. 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.