|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.vub.at.objects.natives.NATNil
edu.vub.at.objects.natives.NATByRef
edu.vub.at.objects.mirrors.NATIntrospectiveMirror
NATIntrospectiveMirror is a default mirror to represent an ambienttalk object which is capable of offering the java meta-interface of any language value at the ambienttalk level. This allows introspection into the language value's internals as well as invoking some meta-level operations on it. Technically, NATMirror is simply a wrapper object around an ambienttalk object which deifies (ups) methods invoked upon it.
Note that whereas the mirror can offer e.g. an apply method when reifying a closure, this does not affect its own meta-interface. A NATMirror is always an object and can thus not be applied at the ambienttalk level.
Example:def clo := { | x | x * 2 }; def m := at.mirrors.Factory.createMirror(clo); clo( 5 ) => 10 (legal) m.apply([5]) => 10 (legal) m( 5 ) => error (Application expected a closure, given a mirror)
Field Summary | |
private ATObject |
principal_
the object reflected on. |
Fields inherited from class edu.vub.at.objects.natives.NATNil |
_INSTANCE_ |
Constructor Summary | |
private |
NATIntrospectiveMirror(ATObject representation)
An introspective mirror is a wrapper which forwards a deified (upped) version of invoked methods and field accesses to its principal. |
Method Summary | |
static ATMirror |
atValue(ATObject objectRepresentation)
Return a mirror on the given native or custom AmbientTalk object. |
ATMirror |
base_asMirror()
|
ATObject |
base_getBase()
Provides access to the AmbientTalk language value this mirror reflects upon. |
boolean |
base_isMirror()
|
ATNil |
meta_assignField(ATObject receiver,
ATSymbol name,
ATObject value)
The effect of assigning a field on a mirror can be twofold. |
ATObject |
meta_clone()
We enforce the restriction that any object has but a single IntrospectiveMirror by returning the mirror itself when asked to clone. |
ATTable |
meta_getStripes()
Returns the stripes of this object. |
ATField |
meta_grabField(ATSymbol fieldName)
Queries an object for one of its field slots. |
ATMethod |
meta_grabMethod(ATSymbol methodName)
Queries an object for one of its method slots. |
ATObject |
meta_invoke(ATObject receiver,
ATSymbol atSelector,
ATTable arguments)
The effect of invoking methods on a mirror (through meta_invoke) consists of checking whether the requested functionality is provided as a meta-operation by the principal that is wrapped by this mirror. |
ATTable |
meta_listFields()
Listing the fields of a mirror requires us to list all of the meta_get methods of the principal + all of the base_get methods of the mirror itself |
ATTable |
meta_listMethods()
Listing the methods of a mirror requires us to list all of the meta_ methods of the principal (excluding meta_get/set methods) + all of the base_ methods (excluding base_get/set methods) of the mirror itself |
ATObject |
meta_newInstance(ATTable init)
This method allows re-initialise a mirror object. |
NATText |
meta_print()
Prints out the object in a human-readable way. |
ATBoolean |
meta_respondsTo(ATSymbol atSelector)
A mirror responds to a message m if and only if: - either its principal has a method named meta_m - or the mirror itself implements a method named base_m |
ATObject |
meta_select(ATObject receiver,
ATSymbol atSelector)
The effect of selecting fields or methods on a mirror (through meta_select) consists of checking whether the requested selector matches a field of the principal wrapped by this mirror. |
Methods inherited from class edu.vub.at.objects.natives.NATByRef |
meta_pass, meta_resolve |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.vub.at.objects.ATObject |
base__opeql__opeql_, base_init, base_new, meta_addField, meta_addMethod, meta_assignVariable, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_lookup, meta_pass, meta_quote, meta_receive, meta_resolve, meta_send, meta_share |
Field Detail |
private final ATObject principal_
Constructor Detail |
private NATIntrospectiveMirror(ATObject representation)
representation
- - the object to reflect upon, which is *not* a NATMirageMethod Detail |
public static final ATMirror atValue(ATObject objectRepresentation)
objectRepresentation
- the object to reflect upon
public ATObject base_getBase()
ATMirror
base_getBase
in interface ATMirror
public boolean base_isMirror()
base_isMirror
in interface ATConversions
base_isMirror
in class NATNil
public ATMirror base_asMirror()
base_asMirror
in interface ATConversions
base_asMirror
in class NATNil
public ATObject meta_invoke(ATObject receiver, ATSymbol atSelector, ATTable arguments) throws InterpreterException
The effect of invoking methods on a mirror (through meta_invoke) consists of checking whether the requested functionality is provided as a meta-operation by the principal that is wrapped by this mirror. This implies the requested selector is sought for at the java-level, albeit prefixed with 'meta_'.
Because an explicit AmbientTalk method invocation must be converted into an implicit Java method invocation, the invocation must be deified ('upped'). To uphold stratification of the mirror architecture, the result of this operation should be a mirror on the result of the Java method invocation.
Note that only when the principal does not have a matching meta_level method the mirror itself will be tested for a corresponding base_level method (e.g. used for operators such as ==). In the latter case, stratification is not enforced. This is due to the fact that these operations are not active at the mirror level, they are base-level operations which happen to be applied on a mirror. An added advantage of this technique is that it permits a mirror to give out a reference to its principal.
meta_invoke
in interface ATObject
meta_invoke
in class NATNil
InterpreterException
public ATObject meta_select(ATObject receiver, ATSymbol atSelector) throws InterpreterException
The effect of selecting fields or methods on a mirror (through meta_select) consists of checking whether the requested selector matches a field of the principal wrapped by this mirror. If this is the case, the principal's ('meta_get' + selector) method will be invoked. Else the selector might identify one of the principal's meta-operations. If this is the case, then an AmbientTalk representation of the Java method ('meta_' + selector) will be returned.
Because an explicit AmbientTalk method invocation must be converted into an implicit Java method invocation, the invocation must be deified ('upped'). To uphold stratification of the mirror architecture, the result of this operation should be a mirror on the result of the Java method invocation.
Note that only when the principal does not have a matching meta_level field or method the mirror itself will be tested for a corresponding base_level behaviour (e.g. for its base field or for operators such as ==). In the latter case, stratification is not enforced. This is due to the fact that the said fields and methods are not meta-level behaviour, rather they are base-level operations which happen to be applicable on a mirror. An added advantage of this technique is that it permits a mirror to have a field referring to its principal.
meta_select
in interface ATObject
meta_select
in class NATNil
InterpreterException
public ATBoolean meta_respondsTo(ATSymbol atSelector) throws InterpreterException
meta_respondsTo
in interface ATObject
meta_respondsTo
in class NATNil
InterpreterException
public ATNil meta_assignField(ATObject receiver, ATSymbol name, ATObject value) throws InterpreterException
meta_assignField
in interface ATObject
meta_assignField
in class NATNil
InterpreterException
public ATField meta_grabField(ATSymbol fieldName) throws InterpreterException
ATObject
meta_grabField
in interface ATObject
meta_grabField
in class NATNil
InterpreterException
public ATMethod meta_grabMethod(ATSymbol methodName) throws InterpreterException
ATObject
meta_grabMethod
in interface ATObject
meta_grabMethod
in class NATNil
InterpreterException
public ATTable meta_listFields() throws InterpreterException
meta_listFields
in interface ATObject
meta_listFields
in class NATNil
InterpreterException
public ATTable meta_listMethods() throws InterpreterException
meta_listMethods
in interface ATObject
meta_listMethods
in class NATNil
InterpreterException
public ATObject meta_clone() throws InterpreterException
meta_clone
in interface ATObject
meta_clone
in class NATNil
InterpreterException
public ATObject meta_newInstance(ATTable init) throws XArityMismatch, XTypeMismatch
meta_newInstance
in interface ATObject
meta_newInstance
in class NATNil
XArityMismatch
XTypeMismatch
public NATText meta_print() throws InterpreterException
ATObject
meta_print
in interface ATObject
meta_print
in class NATNil
InterpreterException
public ATTable meta_getStripes() throws InterpreterException
ATObject
meta_getStripes
in interface ATObject
meta_getStripes
in class NATNil
InterpreterException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |