The base class for Function objects
See ECMA 15.3.
construct
public Scriptable construct(Context cx,
Scriptable scope,
Object[] args)
Call the function as a constructor.
This method is invoked by the runtime in order to satisfy a use
of the JavaScript new
operator. This method is
expected to create a new object and return it.
- construct in interface Function
cx
- the current Context for this threadscope
- an enclosing scope of the caller except
when the function is called from a closure.args
- the array of arguments
createObject
public Scriptable createObject(Context cx,
Scriptable scope)
Creates new script object.
The default implementation of
construct(Context,Scriptable,Object[])
uses the method to
to get the value for
thisObj argument when invoking
call(Context,Scriptable,Scriptable,Object[])
.
The methos is allowed to return
null to indicate that
call(Context,Scriptable,Scriptable,Object[])
will create a new object itself. In this case
construct(Context,Scriptable,Object[])
will set scope and prototype on the result
call(Context,Scriptable,Scriptable,Object[])
unless they are already set.
getArity
public int getArity()
getClassName
public String getClassName()
Get the name of the set of objects implemented by this Java class.
This corresponds to the [[Class]] operation in ECMA and is used
by Object.prototype.toString() in ECMA.
See ECMA 8.6.2 and 15.2.4.2.
- getClassName in interface Scriptable
- getClassName in interface ScriptableObject
getClassPrototype
protected Scriptable getClassPrototype()
getFunctionName
public String getFunctionName()
getInstanceIdValue
protected Object getInstanceIdValue(int id)
Get id value.
If id value is constant, descendant can call cacheIdValue to store
value in the permanent cache.
Default implementation creates IdFunctionObject instance for given id
and cache its value
- getInstanceIdValue in interface IdScriptableObject
getLength
public int getLength()
hasInstance
public boolean hasInstance(Scriptable instance)
Implements the instanceof operator for JavaScript Function objects.
foo = new Foo();
foo instanceof Foo; // true
- hasInstance in interface Scriptable
- hasInstance in interface ScriptableObject
instance
- The value that appeared on the LHS of the instanceof
operator
- true if the "prototype" property of "this" appears in
value's prototype chain
setImmunePrototypeProperty
public void setImmunePrototypeProperty(Object value)
Make value as DontEnum, DontDelete, ReadOnly
prototype property of this Function object
setInstanceIdValue
protected void setInstanceIdValue(int id,
Object value)
Set or delete id value. If value == NOT_FOUND , the implementation
should make sure that the following getInstanceIdValue return NOT_FOUND.
- setInstanceIdValue in interface IdScriptableObject