Fan

 

Reflection

Pods

Pod.list                       // list the pods installed
Pod.find("comAcmeFoo")         // find a pod (throws exception if not found)
Pod.find("comAcmeFoo", false)  // find a pod (returns null if not found)
p.name                         // pod name
p.version                      // pod version
p.facets                       // map of all pod facets
p.facet(@podBuildTime")        // lookup a pod facet
p.facet(@podBuildHost, "-")    // lookup a pod facet with default
p.files[`/img/icon.png`]       // lookup a resource file in myPod

Types

someObj.type                   // get the type of the an object
myPod.types                    // list the types in myPod
myPod.findType("Foo")          // find a type within myPod by its simple name
myPod.findType("Foo", false)   // returns null if type not found
Type.find("myPod::Foo")        // lookup a type by its qualified name
Type.find("myPod::Foo", false) // returns null if type not found
Int#                           // type literal for sys::Int
Int?[]#                        // type literal for sys::Int?[]
t.fits(Num#)                   // reflective version of is/instanceof operator
t.type.pod                     // get the pod of a type
t.qname                        // qualified name of type
t.name                         // simple unqualified name of type
t.base                         // type's base class
t.mixins                       // type's mixins or empty list
t.signature                    // formal type signature
t.make                         // make an obj of type t
t.make([arg0, arg1])           // make an obj of type t with arguments
t.facets                       // map of all declared facets
t.facets(true)                 // map of all inherited facets
t.facet(@serializable)         // lookup facet
t.facet(@facet, "x")           // lookup facet with default
t.facet(@facet, null, true)    // lookup inherited facet

Slots

someType.slot("xyz")           // lookup the slot called xyz on someType
someType.slots                 // list all the slots on someType
Slot.find("myPod::Foo.xyz")    // looukp a slot by its qualified name
Slot.find(qname, false)        // returns null if slot not found
Foo#xyz                        // slot literal
#xyz                           // slot literal (in enclosing class)
s.qname                        // qualified name
s.name                         // unqualified simple name
s.parent                       // declaring type
s.signature                    // full signature of field or method
s.facets                       // map of all facets
s.facet(@facet)                // lookup facet
s.facet(@facet, "x")           // lookup facet with default

Methods

someType.method("x")           // lookup the method called xyz on someType
someType.method("x", null)     // returns null if method not found
someType.methods               // list all the methods on someType
Slot.findMethod("p::Foo.x")    // looukp a method by its qualified name
Slot.findMethod(qname, false)  // returns null if method not found
m.returns                      // return type of method
m.params                       // list of parameters
m.callList([arg0, arg1])       // invoke static method using reflection
m.call(arg0, arg1)              // same as above
m.callOn(self, [arg0, arg1])   // invoke instance method using reflection
m.call([self, arg0, arg1])     // same as above
m.func                         // the function which implements the method

Fields

someType.field("x")            // lookup the field called xyz on someType
someType.field("x", null)      // returns null if field not found
someType.fields                // list all the fields on someType
Slot.findField("p::Foo.x")     // looukp a field by its qualified name
Slot.findField(qname, false)   // returns null if field not found
f.of                           // type of field
f.get                          // get static field
f.get(self)                    // get instance field
f.set(self, val)               // set instance field

Symbols

somePod.symbol("x")            // lookup the symbol called x on somePod
somePod.symbols                // list all the symbols on somePod
Symbol.find("somePod::x")      // looukp a symbol by its qualified name
@somePod::x                    // qualified symbol literal
@x                             // unqualified symbol literal
s.of                           // type of symbol
s.val                          // value of symbol