Package org.mozilla.javascript
Class IdScriptableObject
- java.lang.Object
-
- org.mozilla.javascript.ScriptableObject
-
- org.mozilla.javascript.IdScriptableObject
-
- All Implemented Interfaces:
java.io.Serializable
,ConstProperties
,DebuggableObject
,IdFunctionCall
,Scriptable
,SymbolScriptable
- Direct Known Subclasses:
BaseFunction
,ES6Generator
,ES6Iterator
,NativeArray
,NativeArrayBuffer
,NativeArrayBufferView
,NativeCall
,NativeCallSite
,NativeContinuation
,NativeGenerator
,NativeIterator
,NativeJSON
,NativeMap
,NativeObject
,NativeRegExp
,NativeSet
,NativeSymbol
,NativeWeakMap
,NativeWeakSet
,TopLevel
,XMLObject
public abstract class IdScriptableObject extends ScriptableObject implements IdFunctionCall
Base class for native object implementation that uses IdFunctionObject to export its methods to script via <class-name>.prototype object. Any descendant should implement at least the following methods: findInstanceIdInfo getInstanceIdName execIdCall methodArity To define non-function properties, the descendant should override getInstanceIdValue setInstanceIdValue to get/set property value and provide its default attributes. To customize initialization of constructor and prototype objects, descendant may override scopeInit or fillConstructorProperties methods.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.mozilla.javascript.ScriptableObject
ScriptableObject.KeyComparator
-
-
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
Constructors Constructor Description IdScriptableObject()
IdScriptableObject(Scriptable scope, Scriptable prototype)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activatePrototypeMap(int maxPrototypeId)
void
defineOwnProperty(Context cx, java.lang.Object key, ScriptableObject desc)
Defines a property on an object.void
delete(java.lang.String name)
Removes a named property from the object.void
delete(Symbol key)
Removes an object like the others, but using a Symbol as the key.java.lang.Object
execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.IdFunctionObject
exportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed)
java.lang.Object
get(java.lang.String name, Scriptable start)
Returns the value of the named property or NOT_FOUND.java.lang.Object
get(Symbol key, Scriptable start)
Another version of Get that supports Symbol keyed properties.int
getAttributes(java.lang.String name)
Get the attributes of a named property.int
getAttributes(Symbol key)
boolean
has(java.lang.String name, Scriptable start)
Returns true if the named property is defined.boolean
has(Symbol key, Scriptable start)
A version of "has" that supports symbols.boolean
hasPrototypeMap()
void
initPrototypeConstructor(IdFunctionObject f)
IdFunctionObject
initPrototypeMethod(java.lang.Object tag, int id, java.lang.String name, int arity)
IdFunctionObject
initPrototypeMethod(java.lang.Object tag, int id, java.lang.String propertyName, java.lang.String functionName, int arity)
IdFunctionObject
initPrototypeMethod(java.lang.Object tag, int id, Symbol key, java.lang.String functionName, int arity)
void
initPrototypeValue(int id, java.lang.String name, java.lang.Object value, int attributes)
void
initPrototypeValue(int id, Symbol key, java.lang.Object value, int attributes)
void
put(java.lang.String name, Scriptable start, java.lang.Object value)
Sets the value of the named property, creating it if need be.void
put(Symbol key, Scriptable start, java.lang.Object value)
Implementation of put required by SymbolScriptable objects.void
setAttributes(java.lang.String name, int attributes)
Set the attributes of a named property.-
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, hasProperty, isConst, isEmpty, isExtensible, isSealed, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
-
-
-
Constructor Detail
-
IdScriptableObject
public IdScriptableObject()
-
IdScriptableObject
public IdScriptableObject(Scriptable scope, Scriptable prototype)
-
-
Method Detail
-
has
public boolean has(java.lang.String name, Scriptable start)
Description copied from class:ScriptableObject
Returns true if the named property is defined.- Specified by:
has
in interfaceScriptable
- Overrides:
has
in classScriptableObject
- Parameters:
name
- the name of the propertystart
- the object in which the lookup began- Returns:
- true if and only if the property was found in the object
- See Also:
Scriptable.get(String, Scriptable)
,ScriptableObject.getProperty(Scriptable, String)
-
has
public boolean has(Symbol key, Scriptable start)
Description copied from class:ScriptableObject
A version of "has" that supports symbols.- Specified by:
has
in interfaceSymbolScriptable
- Overrides:
has
in classScriptableObject
-
get
public java.lang.Object get(java.lang.String name, Scriptable start)
Description copied from class:ScriptableObject
Returns the value of the named property or NOT_FOUND. If the property was created using defineProperty, the appropriate getter method is called.- Specified by:
get
in interfaceScriptable
- Overrides:
get
in classScriptableObject
- Parameters:
name
- the name of the propertystart
- the object in which the lookup began- Returns:
- the value of the property (may be null), or NOT_FOUND
- See Also:
Context.getUndefinedValue()
-
get
public java.lang.Object get(Symbol key, Scriptable start)
Description copied from class:ScriptableObject
Another version of Get that supports Symbol keyed properties.- Specified by:
get
in interfaceSymbolScriptable
- Overrides:
get
in classScriptableObject
-
put
public void put(java.lang.String name, Scriptable start, java.lang.Object value)
Description copied from class:ScriptableObject
Sets the value of the named property, creating it if need be. If the property was created using defineProperty, the appropriate setter method is called.If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object.
- Specified by:
put
in interfaceScriptable
- Overrides:
put
in classScriptableObject
- Parameters:
name
- the name of the propertystart
- the object whose property is being setvalue
- value to set the property to- See Also:
Scriptable.has(String, Scriptable)
,Scriptable.get(String, Scriptable)
,ScriptableObject.putProperty(Scriptable, String, Object)
,Context.toObject(Object, Scriptable)
-
put
public void put(Symbol key, Scriptable start, java.lang.Object value)
Description copied from class:ScriptableObject
Implementation of put required by SymbolScriptable objects.- Specified by:
put
in interfaceSymbolScriptable
- Overrides:
put
in classScriptableObject
-
delete
public void delete(java.lang.String name)
Description copied from class:ScriptableObject
Removes a named property from the object. If the property is not found, or it has the PERMANENT attribute, no action is taken.- Specified by:
delete
in interfaceScriptable
- Overrides:
delete
in classScriptableObject
- Parameters:
name
- the name of the property- See Also:
Scriptable.get(String, Scriptable)
,ScriptableObject.deleteProperty(Scriptable, String)
-
delete
public void delete(Symbol key)
Description copied from class:ScriptableObject
Removes an object like the others, but using a Symbol as the key.- Specified by:
delete
in interfaceSymbolScriptable
- Overrides:
delete
in classScriptableObject
-
getAttributes
public int getAttributes(java.lang.String name)
Description copied from class:ScriptableObject
Get the attributes of a named property. The property is specified byname
as defined forhas
.- Overrides:
getAttributes
in classScriptableObject
- Parameters:
name
- the identifier for the property- Returns:
- the bitset of attributes
- See Also:
ScriptableObject.has(String, Scriptable)
,ScriptableObject.READONLY
,ScriptableObject.DONTENUM
,ScriptableObject.PERMANENT
,ScriptableObject.EMPTY
-
getAttributes
public int getAttributes(Symbol key)
- Overrides:
getAttributes
in classScriptableObject
-
setAttributes
public void setAttributes(java.lang.String name, int attributes)
Description copied from class:ScriptableObject
Set the attributes of a named property. The property is specified byname
as defined forhas
.The possible attributes are READONLY, DONTENUM, and PERMANENT. Combinations of attributes are expressed by the bitwise OR of attributes. EMPTY is the state of no attributes set. Any unused bits are reserved for future use.
- Overrides:
setAttributes
in classScriptableObject
- Parameters:
name
- the name of the propertyattributes
- the bitset of attributes- See Also:
Scriptable.has(String, Scriptable)
,ScriptableObject.READONLY
,ScriptableObject.DONTENUM
,ScriptableObject.PERMANENT
,ScriptableObject.EMPTY
-
execIdCall
public java.lang.Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args)
'thisObj' will be null if invoked as constructor, in which case instance of Scriptable should be returned.- Specified by:
execIdCall
in interfaceIdFunctionCall
-
exportAsJSClass
public final IdFunctionObject exportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed)
-
hasPrototypeMap
public final boolean hasPrototypeMap()
-
activatePrototypeMap
public final void activatePrototypeMap(int maxPrototypeId)
-
initPrototypeMethod
public final IdFunctionObject initPrototypeMethod(java.lang.Object tag, int id, java.lang.String name, int arity)
-
initPrototypeMethod
public final IdFunctionObject initPrototypeMethod(java.lang.Object tag, int id, java.lang.String propertyName, java.lang.String functionName, int arity)
-
initPrototypeMethod
public final IdFunctionObject initPrototypeMethod(java.lang.Object tag, int id, Symbol key, java.lang.String functionName, int arity)
-
initPrototypeConstructor
public final void initPrototypeConstructor(IdFunctionObject f)
-
initPrototypeValue
public final void initPrototypeValue(int id, java.lang.String name, java.lang.Object value, int attributes)
-
initPrototypeValue
public final void initPrototypeValue(int id, Symbol key, java.lang.Object value, int attributes)
-
defineOwnProperty
public void defineOwnProperty(Context cx, java.lang.Object key, ScriptableObject desc)
Description copied from class:ScriptableObject
Defines a property on an object.- Overrides:
defineOwnProperty
in classScriptableObject
- Parameters:
cx
- the current Contextkey
- the name/index of the propertydesc
- the new property descriptor, as described in 8.6.1
-
-