org.mozilla.javascript

Class BaseFunction

Implemented Interfaces:
Callable, ConstProperties, DebuggableObject, Function, IdFunctionCall, Scriptable, Serializable
Known Direct Subclasses:
FunctionObject, IdFunctionObject, NativeFunction, NativeJavaConstructor, NativeJavaMethod

public class BaseFunction
extends IdScriptableObject
implements Function

The base class for Function objects See ECMA 15.3.
Author:
Norris Boyd

Field Summary

Fields inherited from class org.mozilla.javascript.ScriptableObject

CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

Fields inherited from interface org.mozilla.javascript.Scriptable

NOT_FOUND

Constructor Summary

BaseFunction()
BaseFunction(Scriptable scope, Scriptable prototype)

Method Summary

@Override
Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
protected @Override
Object getInstanceIdValue(int id)
@Override
String getClassName()
protected @Override
String getInstanceIdName(int id)
@Override
boolean hasInstance(Scriptable instance)
Implements the instanceof operator for JavaScript Function objects.
Object
call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
Should be overridden.
Scriptable
construct(Context cx, Scriptable scope, Object[] args)
Call the function as a constructor.
Scriptable
createObject(Context cx, Scriptable scope)
Creates new script object.
int
getArity()
protected Scriptable
getClassPrototype()
String
getFunctionName()
int
getLength()
protected @Override
int findInstanceIdInfo(String s)
protected @Override
int findPrototypeId(String s)
protected @Override
int getMaxInstanceId()
void
setImmunePrototypeProperty(Object value)
Make value as DontEnum, DontDelete, ReadOnly prototype property of this Function object
protected @Override
void fillConstructorProperties(IdFunctionObject ctor)
protected @Override
void initPrototypeId(int id)
protected @Override
void setInstanceIdValue(int id, Object value)

Methods inherited from class org.mozilla.javascript.IdScriptableObject

Object get, activatePrototypeMap, addIdFunctionProperty, boolean has, defaultGet, defaultPut, execIdCall, exportAsJSClass, fillConstructorProperties, findInstanceIdInfo, findPrototypeId, getInstanceIdName, getInstanceIdValue, getMaxInstanceId, hasPrototypeMap, incompatibleCallError, initPrototypeConstructor, initPrototypeId, initPrototypeMethod, initPrototypeValue, instanceIdInfo, int getAttributes, setInstanceIdValue, void delete, void put, void setAttributes

Methods inherited from class org.mozilla.javascript.ScriptableObject

associateValue, avoidObjectDetection, callMethod, callMethod, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, equivalentValues, extends Scriptable> String defineClass, extends Scriptable> void defineClass, extends Scriptable> void defineClass, get, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isGetterOrSetter, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype

Constructor Details

BaseFunction

public BaseFunction()

BaseFunction

public BaseFunction(Scriptable scope,
                    Scriptable prototype)

Method Details

Object execIdCall

public @Override Object execIdCall(IdFunctionObject f,
                                   Context cx,
                                   Scriptable scope,
                                   Scriptable thisObj,
                                   Object[] args)

Object getInstanceIdValue

protected @Override Object getInstanceIdValue(int id)

String getClassName

public @Override String getClassName()

String getInstanceIdName

protected @Override String getInstanceIdName(int id)

boolean hasInstance

public @Override boolean hasInstance(Scriptable instance)
Implements the instanceof operator for JavaScript Function objects.

foo = new Foo();
foo instanceof Foo; // true

Parameters:
instance - The value that appeared on the LHS of the instanceof operator
Returns:
true if the "prototype" property of "this" appears in value's prototype chain

call

public Object call(Context cx,
                   Scriptable scope,
                   Scriptable thisObj,
                   Object[] args)
Should be overridden.
Specified by:
call in interface Function
call in interface Callable

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.
Specified by:
construct in interface Function
Parameters:
cx - the current Context for this thread
scope - an enclosing scope of the caller except when the function is called from a closure.
args - the array of arguments
Returns:
the allocated object

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()

getClassPrototype

protected Scriptable getClassPrototype()

getFunctionName

public String getFunctionName()

getLength

public int getLength()

int findInstanceIdInfo

protected @Override int findInstanceIdInfo(String s)

int findPrototypeId

protected @Override int findPrototypeId(String s)

int getMaxInstanceId

protected @Override int getMaxInstanceId()

setImmunePrototypeProperty

public void setImmunePrototypeProperty(Object value)
Make value as DontEnum, DontDelete, ReadOnly prototype property of this Function object

void fillConstructorProperties

protected @Override void fillConstructorProperties(IdFunctionObject ctor)

void initPrototypeId

protected @Override void initPrototypeId(int id)

void setInstanceIdValue

protected @Override void setInstanceIdValue(int id,
                                            Object value)