|
|||||||||||
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.natives.NATClosure
edu.vub.at.objects.mirrors.NativeClosure
A NativeClosure is a wrapper class for a piece of Java code. The Java code is presented to the AmbientTalk system as a closure. A NativeClosure is represented as follows: - Its encapsulating method is a 'dummy' NativeMethod ATMethod, with the following properties: - name = "nativelambda" (to distinguish it from 'ordinary' lambdas) - arguments = [ \@args ] (it takes an arbitrary number of arguments) - body = "Native implementation in {class}" (a string telling an inspector that this closure is natively implemented in the given Java class) - applying a nativelambda directly (without going through this NativeClosure) results in an error - Its enclosed context consists of a triple (obj, obj, obj.super), where 'obj' is the Java object (implementing ATObject) that created this NativeClosure. The method and context fields of a NativeClosure are lazily generated on demand for efficiency reasons. Most of the time, a NativeClosure will not be introspected, but only applied. A NativeClosure can be used in two ways by Java code: 1) As a generator for anonymous classes to generate 'anonymous lambdas': new NativeClosure(this) { public ATObject meta_apply(ATTable args) throws NATException { ... } } 2) As a wrapper for an already existing NativeMethod: new NativeClosure(this, aJavaMethod);
Nested Class Summary |
Nested classes inherited from class edu.vub.at.objects.natives.NATClosure |
|
Field Summary | |
protected ATObject |
scope_
|
Fields inherited from class edu.vub.at.objects.natives.NATClosure |
context_, method_ |
Fields inherited from class edu.vub.at.objects.natives.NATNil |
_INSTANCE_ |
Constructor Summary | |
NativeClosure(ATObject scope)
Create a new NativeClosure where meta_apply will be overridden by anonymous subclasses. |
|
NativeClosure(ATObject scope,
NativeMethod meth)
Create a new NativeClosure where meta_apply will invoke the given Java Method. |
Method Summary | |
ATObject |
base_apply(ATTable arguments)
Apply the NativeClosure, which either gives rise to executing a native piece of code supplied by an anonymous subclass, or executes the wrapped NativeMethod. |
ATObject |
base_applyInScope(ATTable args,
ATObject scope)
A NativeClosure can also be directed to execute its wrapped NativeMethod in an externally specified scope. |
ATContext |
base_getContext()
Overridden to allow for lazy instantiation of the context. |
ATMethod |
base_getMethod()
Overridden to allow for lazy instantiation of the method. |
void |
checkArity(ATTable args,
int required)
|
ATObject |
get(ATTable args,
int n)
Auxiliary method to more easily extract arguments from an ATTable |
boolean |
getBln(ATTable args,
int n)
|
double |
getFrc(ATTable args,
int n)
|
int |
getNbr(ATTable args,
int n)
|
java.lang.Object[] |
getTab(ATTable args,
int n)
|
java.lang.String |
getTxt(ATTable args,
int n)
|
NATText |
meta_print()
Prints out the object in a human-readable way. |
Methods inherited from class edu.vub.at.objects.natives.NATClosure |
base_asClosure, base_escape, base_isClosure, base_whileTrue_, meta_getStripes |
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_assignField, meta_assignVariable, meta_clone, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_newInstance, meta_pass, meta_quote, meta_receive, meta_resolve, meta_respondsTo, meta_select, meta_send, meta_share |
Field Detail |
protected final ATObject scope_
Constructor Detail |
public NativeClosure(ATObject scope)
scope
- the object creating this NativeClosure.public NativeClosure(ATObject scope, NativeMethod meth)
scope
- the object that should be used as a receiver for the corresponding method.meth
- a presumably native methodMethod Detail |
public ATMethod base_getMethod()
base_getMethod
in interface ATClosure
base_getMethod
in class NATClosure
public ATContext base_getContext() throws InterpreterException
base_getContext
in interface ATClosure
base_getContext
in class NATClosure
InterpreterException
public ATObject base_apply(ATTable arguments) throws InterpreterException
base_apply
in interface ATClosure
base_apply
in class NATClosure
InterpreterException
public ATObject base_applyInScope(ATTable args, ATObject scope) throws InterpreterException
base_applyInScope
in interface ATClosure
base_applyInScope
in class NATClosure
InterpreterException
public NATText meta_print() throws InterpreterException
ATObject
meta_print
in interface ATObject
meta_print
in class NATClosure
InterpreterException
public ATObject get(ATTable args, int n) throws InterpreterException
InterpreterException
public int getNbr(ATTable args, int n) throws InterpreterException
InterpreterException
public double getFrc(ATTable args, int n) throws InterpreterException
InterpreterException
public java.lang.String getTxt(ATTable args, int n) throws InterpreterException
InterpreterException
public boolean getBln(ATTable args, int n) throws InterpreterException
InterpreterException
public java.lang.Object[] getTab(ATTable args, int n) throws InterpreterException
InterpreterException
public void checkArity(ATTable args, int required) throws InterpreterException
InterpreterException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |