CrossClj

1.10.0-alpha4 docs

SourceDocs



RECENT
    VARS
    ->AsmReflector
    ->Constructor
    ->Field
    ->JavaReflector
    ->Method
    access-flag
    ClassResolver
    constructor->map
    declared-constructors
    declared-fields
    declared-methods
    default-reflector
    field->map
    field-descriptor->class-symbol
    flag-descriptors
    internal-name->class-symbol
    map->Constructor
    map->Field
    map->Method
    method->map
    parse-flags
    parse-method-descriptor
    reflect
    Reflector
    resource-name
    type-reflect
    TypeReference
    typesym

    « Index of all namespaces of this project

    Reflection on Host Types
    Alpha - subject to change.
    
    Two main entry points: 
    
    * type-reflect reflects on something that implements TypeReference.
    * reflect (for REPL use) reflects on the class of an instance, or
      on a class if passed a class
    
    Key features:
    
    * Exposes the read side of reflection as pure data. Reflecting
      on a type returns a map with keys :bases, :flags, and :members.
    
    * Canonicalizes class names as Clojure symbols. Types can extend
      to the TypeReference protocol to indicate that they can be
      unambiguously resolved as a type name. The canonical format
      requires one non-Java-ish convention: array brackets are <>
      instead of [] so they can be part of a Clojure symbol.
    
    * Pluggable Reflectors for different implementations. The default
      JavaReflector is good when you have a class in hand, or use
      the AsmReflector for "hands off" reflection without forcing
      classes to load.
    
    Platform implementers must:
    
    * Create an implementation of Reflector.
    * Create one or more implementations of TypeReference.
    * def default-reflector to be an instance that satisfies Reflector.

    — Stuart Halloway

    (->AsmReflector class-resolver)
    Positional factory function for class clojure.reflect.AsmReflector.
    
    (->Constructor name declaring-class parameter-types exception-types flags)
    Positional factory function for class clojure.reflect.Constructor.
    
    (->Field name type declaring-class flags)
    Positional factory function for class clojure.reflect.Field.
    
    (->JavaReflector classloader)
    Positional factory function for class clojure.reflect.JavaReflector.
    
    (->Method name return-type declaring-class parameter-types exception-types flags)
    Positional factory function for class clojure.reflect.Method.
    
    Private
    (access-flag [name flag & contexts])
    protocol
    (resolve-class this name)
    Given a class name, return that typeref's class bytes as an InputStream.
    
    Private
    (constructor->map constructor)
    Private
    (declared-constructors cls)
    Return a set of the declared constructors of class as a Clojure map.
    
    Private
    (declared-fields cls)
    Return a set of the declared fields of class as a Clojure map.
    
    Private
    (declared-methods cls)
    Return a set of the declared constructors of class as a Clojure map.
    
    Private
    (field->map field)
    Private
    (field-descriptor->class-symbol d)
    Convert a Java field descriptor to a Clojure class symbol. Field
    descriptors are described in section 4.3.2 of the JVM spec, 2nd ed.:
    http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#14152
    The Java access bitflags, along with their friendly names and
    the kinds of objects to which they can apply.
    Private
    (internal-name->class-symbol d)
    Convert a Java internal name to a Clojure class symbol. Internal
    names uses slashes instead of dots, e.g. java/lang/String. See
    Section 4.2 of the JVM spec, 2nd ed.:
    
    http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#14757
    (map->Constructor m__7585__auto__)
    Factory function for class clojure.reflect.Constructor, taking a map of keywords to field values.
    
    (map->Field m__7585__auto__)
    Factory function for class clojure.reflect.Field, taking a map of keywords to field values.
    
    (map->Method m__7585__auto__)
    Factory function for class clojure.reflect.Method, taking a map of keywords to field values.
    
    Private
    (method->map method)
    Private
    (parse-flags flags context)
    Convert reflection bitflags into a set of keywords.
    
    Private
    (parse-method-descriptor md)
    (reflect obj & options)
    Alpha - subject to change.
    Reflect on the type of obj (or obj itself if obj is a class).
    Return value and options are the same as for type-reflect. 
    protocol
    Protocol for reflection implementers.
    
    (do-reflect reflector typeref)
    Private
    (resource-name typeref)
    Given a typeref, return implied resource name. Used by Reflectors
    such as ASM that need to find and read classbytes from files.
    (type-reflect typeref & options)
    Alpha - subject to change.
     Reflect on a typeref, returning a map with :bases, :flags, and
    :members. In the discussion below, names are always Clojure symbols.
    
     :bases            a set of names of the type's bases
     :flags            a set of keywords naming the boolean attributes
                       of the type.
     :members          a set of the type's members. Each member is a map
                       and can be a constructor, method, or field.
    
     Keys common to all members:
     :name             name of the type 
     :declaring-class  name of the declarer
     :flags            keyword naming boolean attributes of the member
    
     Keys specific to constructors:
     :parameter-types  vector of parameter type names
     :exception-types  vector of exception type names
    
     Key specific to methods:
     :parameter-types  vector of parameter type names
     :exception-types  vector of exception type names
     :return-type      return type name
    
     Keys specific to fields:
     :type             type name
    
     Options:
    
       :ancestors     in addition to the keys described above, also
                      include an :ancestors key with the entire set of
                      ancestors, and add all ancestor members to
                      :members.
       :reflector     implementation to use. Defaults to JavaReflector,
                      AsmReflector is also an option.
    protocol
    A TypeReference can be unambiguously converted to a type name on
    the host platform.
    
    All typerefs are normalized into symbols. If you need to
    normalize a typeref yourself, call typesym.
    (typename o)
    Returns Java name as returned by ASM getClassName, e.g. byte[], java.lang.String[]
    
    Private
    (typesym t)
    Given a typeref, create a legal Clojure symbol version of the
    type's name.