Package clojure.lang

Examples of clojure.lang.Symbol


      return o instanceof Symbol ? (Symbol)o : null;
  }
 
  private static boolean isPrivate (List form) {
      if (form.size() < 2) return false;
      Symbol def = symbol(RT.first(form));
      Symbol name = symbol(RT.second(form));
      if (def == null || name == null) return false;
      return def.getName().matches("(defn-|defvar-)") ||
          (name.meta() != null && name.meta().valAt(Keyword.intern("private"), false).equals(Boolean.TRUE));
  }
View Full Code Here


  protected void setInputInUiThread (List<List> forms) {
      if (sort) {
          List<List> sorted = new ArrayList(forms);
            Collections.sort(sorted, new Comparator<List> () {
                public int compare(List o1, List o2) {
                    Symbol s1 = symbol(RT.first(o1)),
                           s2 = symbol(RT.first(o2));
                   
                    if (s1 == null && s2 == null) return 0; // mandatory for Comparator contract
                    if (s1 == null) return 1;
                    if (s2 == null) return -1;
                   
                    if (s1.getName().equals("ns") && s2.getName().equals("ns")) {
                      // fall through to order ns decls correctly
                    } else {
                      if (s1.getName().equals("ns")) return -1;
                      if (s2.getName().equals("ns")) return 1;
                    }
                   
                    if (isPrivate(o1) != isPrivate(o2)) {
                        return isPrivate(o1) ? -1 : 1;
                    }
                   
                    s1 = symbol(RT.second(o1));
                    s2 = symbol(RT.second(o2));
                   
                    if (s1 == null && s2 == null) return 0; // mandatory for Comparator contract
                    if (s1 == null) return 1;
                    if (s2 == null) return -1;
                   
                    return s1.getName().compareToIgnoreCase(s2.getName());
                }
            });
            forms = sorted;
      }
      final List<List> theForms = forms;
View Full Code Here

*
* @author Sam
*/
public class ClojureConsole {
    public static void main(String[] args) {
        Symbol CLOJURE_MAIN = Symbol.intern("clojure.main");
        Var REQUIRE = RT.var("clojure.core", "require");
        Var MAIN = RT.var("clojure.main", "main");
        try {
            REQUIRE.invoke(CLOJURE_MAIN);
            MAIN.applyTo(RT.seq(new String[]{}));
View Full Code Here

    if (bindings != null)
    {
      final Set<Entry<String, Object>> entrySet = bindings.entrySet();
      for (final Entry<String, Object> entry : entrySet)
      {
        final Symbol symbol = Symbol.intern(entry.getKey());
        final Namespace userNs = Namespace.findOrCreate(Symbol.create("user".intern()));
        final Var var = Var.intern(userNs, symbol);
        var.setDynamic(true);
        mappings = mappings.assoc(var, entry.getValue());
      }
View Full Code Here

        try {
            String location = PolyglotModelUtil.getLocation(options);

            final Var USE = Var.intern(RT.CLOJURE_NS, Symbol.create("use"));
            final Symbol READER = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.reader");
            final Symbol LEININGEN = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.leiningen");
            USE.invoke(READER);
            USE.invoke(LEININGEN);
            clojure.lang.Compiler.load(input, location, location);
            final Var MODEL = Var.intern(Namespace.findOrCreate(READER), Symbol.create("*MODEL*"));
            return  (Model) ((Atom) MODEL.get()).deref();
View Full Code Here

public class ClojureModelWriter extends ModelWriterSupport {

    public void write(Writer writer, Map<String, Object> stringObjectMap, Model model) throws IOException {
        try {
            final Var REQUIRE = Var.intern(RT.CLOJURE_NS, Symbol.create("require"));
            final Symbol REFLECTOR = Symbol.create("org.sonatype.maven.polyglot.clojure.dsl.writer");
            REQUIRE.invoke(REFLECTOR);
            final Var WRITER = Var.intern(Namespace.findOrCreate(REFLECTOR), Symbol.create("write-model"));
            WRITER.invoke(model, writer);
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of clojure.lang.Symbol

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.