Class IdScriptableObject
- All Implemented Interfaces:
Serializable,ConstProperties,DebuggableObject,IdFunctionCall,Scriptable,SymbolScriptable
- Direct Known Subclasses:
BaseFunction,ES6Generator,ES6Iterator,NativeArray,NativeCall,NativeCallSite,NativeConsole,NativeContinuation,NativeGenerator,NativeIterator,NativeMap,NativeObject,NativeRegExp,NativeSet,NativeWeakMap,NativeWeakSet,TopLevel,XMLObject
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:
-
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_CONSTFields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidactivatePrototypeMap(int maxPrototypeId) protected voidaddIdFunctionProperty(Scriptable obj, Object tag, int id, String name, int arity) protected final ObjectdefaultGet(String name) protected final booleandefaultHas(String name) protected final voiddefaultPut(String name, Object value) protected voiddefineOwnProperty(Context cx, Object key, ScriptableObject desc, boolean checkValid) Defines a property on an object.voidRemoves a named property from the object.voidRemoves an object like the others, but using a Symbol as the key.protected static <T> TensureType(Object obj, Class<T> clazz, String functionName) protected static <T> TensureType(Object obj, Class<T> clazz, IdFunctionObject f) Utility method to check the type and do the cast or throw an incompatible call error.execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) 'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.final IdFunctionObjectexportAsJSClass(int maxPrototypeId, Scriptable scope, boolean sealed) protected voidprotected intfindInstanceIdInfo(String name) Map name to id of instance property.protected intfindInstanceIdInfo(Symbol key) Map name to id of instance property.protected intfindPrototypeId(String name) protected intfindPrototypeId(Symbol key) get(String name, Scriptable start) Returns the value of the named property or NOT_FOUND.get(Symbol key, Scriptable start) Another version of Get that supports Symbol keyed properties.intgetAttributes(String name) Get the attributes of a named property.intgetAttributes(Symbol key) protected StringgetInstanceIdName(int id) Map id back to property name it defines.protected ObjectgetInstanceIdValue(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 valueprotected intGet maximum id findInstanceIdInfo can generate.protected ScriptableObjectgetOwnPropertyDescriptor(Context cx, Object id) booleanhas(String name, Scriptable start) Returns true if the named property is defined.booleanhas(Symbol key, Scriptable start) A version of "has" that supports symbols.final booleanfinal voidprotected voidinitPrototypeId(int id) final IdFunctionObjectinitPrototypeMethod(Object tag, int id, String name, int arity) final IdFunctionObjectinitPrototypeMethod(Object tag, int id, String propertyName, String functionName, int arity) final IdFunctionObjectinitPrototypeMethod(Object tag, int id, Symbol key, String functionName, int arity) final voidinitPrototypeValue(int id, String name, Object value, int attributes) final voidinitPrototypeValue(int id, Symbol key, Object value, int attributes) protected static intinstanceIdInfo(int attributes, int id) voidput(String name, Scriptable start, Object value) Sets the value of the named property, creating it if need be.voidput(Symbol key, Scriptable start, Object value) Implementation of put required by SymbolScriptable objects.voidsetAttributes(String name, int attributes) Set the attributes of a named property.protected voidsetInstanceIdAttributes(int id, int attr) Update the attributes of the given instance property.protected voidsetInstanceIdValue(int id, Object value) Set or delete id value.Methods inherited from class org.mozilla.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, equivalentValues, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getClassName, getClassPrototype, getDefaultValue, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasInstance, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, size
-
Constructor Details
-
IdScriptableObject
public IdScriptableObject() -
IdScriptableObject
-
-
Method Details
-
defaultHas
-
defaultGet
-
defaultPut
-
has
Description copied from class:ScriptableObjectReturns true if the named property is defined.- Specified by:
hasin interfaceScriptable- Overrides:
hasin 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:
-
has
Description copied from class:ScriptableObjectA version of "has" that supports symbols.- Specified by:
hasin interfaceSymbolScriptable- Overrides:
hasin classScriptableObject
-
get
Description copied from class:ScriptableObjectReturns the value of the named property or NOT_FOUND.If the property was created using defineProperty, the appropriate getter method is called.
- Specified by:
getin interfaceScriptable- Overrides:
getin 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:
-
get
Description copied from class:ScriptableObjectAnother version of Get that supports Symbol keyed properties.- Specified by:
getin interfaceSymbolScriptable- Overrides:
getin classScriptableObject
-
put
Description copied from class:ScriptableObjectSets 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:
putin interfaceScriptable- Overrides:
putin classScriptableObject- Parameters:
name- the name of the propertystart- the object whose property is being setvalue- value to set the property to- See Also:
-
put
Description copied from class:ScriptableObjectImplementation of put required by SymbolScriptable objects.- Specified by:
putin interfaceSymbolScriptable- Overrides:
putin classScriptableObject
-
delete
Description copied from class:ScriptableObjectRemoves a named property from the object.If the property is not found, or it has the PERMANENT attribute, no action is taken.
- Specified by:
deletein interfaceScriptable- Overrides:
deletein classScriptableObject- Parameters:
name- the name of the property- See Also:
-
delete
Description copied from class:ScriptableObjectRemoves an object like the others, but using a Symbol as the key.- Specified by:
deletein interfaceSymbolScriptable- Overrides:
deletein classScriptableObject
-
getAttributes
Description copied from class:ScriptableObjectGet the attributes of a named property.The property is specified by
nameas defined forhas.- Overrides:
getAttributesin classScriptableObject- Parameters:
name- the identifier for the property- Returns:
- the bitset of attributes
- See Also:
-
getAttributes
- Overrides:
getAttributesin classScriptableObject
-
setAttributes
Description copied from class:ScriptableObjectSet the attributes of a named property.The property is specified by
nameas 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:
setAttributesin classScriptableObject- Parameters:
name- the name of the propertyattributes- the bitset of attributes- See Also:
-
getMaxInstanceId
protected int getMaxInstanceId()Get maximum id findInstanceIdInfo can generate. -
instanceIdInfo
protected static int instanceIdInfo(int attributes, int id) -
findInstanceIdInfo
Map name to id of instance property. Should return 0 if not found or the result ofinstanceIdInfo(int, int). -
findInstanceIdInfo
Map name to id of instance property. Should return 0 if not found or the result ofinstanceIdInfo(int, int). -
getInstanceIdName
Map id back to property name it defines. -
getInstanceIdValue
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 -
setInstanceIdValue
Set or delete id value. If value == NOT_FOUND , the implementation should make sure that the following getInstanceIdValue return NOT_FOUND. -
setInstanceIdAttributes
protected void setInstanceIdAttributes(int id, int attr) Update the attributes of the given instance property. Classes which want to support changing property attributes via Object.defineProperty must override this method. The default implementation throws InternalError.- Parameters:
id- the instance property idattr- the new attribute bitset
-
execIdCall
public Object execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) 'thisObj' will be null if invoked as constructor, in which case * instance of Scriptable should be returned.- Specified by:
execIdCallin interfaceIdFunctionCall
-
exportAsJSClass
-
hasPrototypeMap
public final boolean hasPrototypeMap() -
activatePrototypeMap
public final void activatePrototypeMap(int maxPrototypeId) -
initPrototypeMethod
-
initPrototypeMethod
public final IdFunctionObject initPrototypeMethod(Object tag, int id, String propertyName, String functionName, int arity) -
initPrototypeMethod
public final IdFunctionObject initPrototypeMethod(Object tag, int id, Symbol key, String functionName, int arity) -
initPrototypeConstructor
-
initPrototypeValue
-
initPrototypeValue
-
initPrototypeId
protected void initPrototypeId(int id) -
findPrototypeId
-
findPrototypeId
-
fillConstructorProperties
-
addIdFunctionProperty
-
ensureType
Utility method to check the type and do the cast or throw an incompatible call error. Possible usage would be to have a private function like realThis:private static NativeSomething realThis(Scriptable thisObj, IdFunctionObject f) { return ensureType(thisObj, NativeSomething.class, f); }- Parameters:
obj- the object to check/castclazz- the target typef- function that is attempting to convert 'this' object.- Returns:
- obj casted to the target type
- Throws:
EcmaError- if the cast failed.
-
ensureType
-
defineOwnProperty
Description copied from class:ScriptableObjectDefines a property on an object.Based on [[DefineOwnProperty]] from 8.12.10 of the spec.
- Overrides:
defineOwnPropertyin classScriptableObject- Parameters:
cx- the current Contextkey- the name/index of the propertydesc- the new property descriptor, as described in 8.6.1checkValid- whether to perform validity checks
-
getOwnPropertyDescriptor
- Overrides:
getOwnPropertyDescriptorin classScriptableObject
-