Class IdScriptableObject

    • Constructor Detail

      • IdScriptableObject

        public IdScriptableObject()
    • Method Detail

      • defaultHas

        protected final boolean defaultHas​(java.lang.String name)
      • defaultGet

        protected final java.lang.Object defaultGet​(java.lang.String name)
      • defaultPut

        protected final void defaultPut​(java.lang.String name,
                                        java.lang.Object value)
      • 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 interface Scriptable
        Overrides:
        get in class ScriptableObject
        Parameters:
        name - the name of the property
        start - the object in which the lookup began
        Returns:
        the value of the property (may be null), or NOT_FOUND
        See Also:
        Context.getUndefinedValue()
      • getIds

        java.lang.Object[] getIds​(boolean getNonEnumerable,
                                  boolean getSymbols)
        Overrides:
        getIds in class ScriptableObject
      • getMaxInstanceId

        protected int getMaxInstanceId()
        Get maximum id findInstanceIdInfo can generate.
      • instanceIdInfo

        protected static int instanceIdInfo​(int attributes,
                                            int id)
      • findInstanceIdInfo

        protected int findInstanceIdInfo​(java.lang.String name)
        Map name to id of instance property. Should return 0 if not found or the result of instanceIdInfo(int, int).
      • findInstanceIdInfo

        protected int findInstanceIdInfo​(Symbol key)
        Map name to id of instance property. Should return 0 if not found or the result of instanceIdInfo(int, int).
      • getInstanceIdName

        protected java.lang.String getInstanceIdName​(int id)
        Map id back to property name it defines.
      • getInstanceIdValue

        protected java.lang.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
      • setInstanceIdValue

        protected void setInstanceIdValue​(int id,
                                          java.lang.Object value)
        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 id
        attr - the new attribute bitset
      • 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)
      • initPrototypeId

        protected void initPrototypeId​(int id)
      • findPrototypeId

        protected int findPrototypeId​(java.lang.String name)
      • findPrototypeId

        protected int findPrototypeId​(Symbol key)
      • fillConstructorProperties

        protected void fillConstructorProperties​(IdFunctionObject ctor)
      • addIdFunctionProperty

        protected void addIdFunctionProperty​(Scriptable obj,
                                             java.lang.Object tag,
                                             int id,
                                             java.lang.String name,
                                             int arity)
      • incompatibleCallError

        protected static EcmaError incompatibleCallError​(IdFunctionObject f)
        Utility method to construct type error to indicate incompatible call when converting script thisObj to a particular type is not possible. Possible usage would be to have a private function like realThis:
          private static NativeSomething realThis(Scriptable thisObj,
                                                  IdFunctionObject f)
          {
              if (!(thisObj instanceof NativeSomething))
                  throw incompatibleCallError(f);
              return (NativeSomething)thisObj;
         }
         
        Note that although such function can be implemented universally via java.lang.Class.isInstance(), it would be much more slower.
        Parameters:
        f - function that is attempting to convert 'this' object.
        Returns:
        Scriptable object suitable for a check by the instanceof operator.
        Throws:
        java.lang.RuntimeException - if no more instanceof target can be found
      • newIdFunction

        private IdFunctionObject newIdFunction​(java.lang.Object tag,
                                               int id,
                                               java.lang.String name,
                                               int arity,
                                               Scriptable scope)
      • 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 class ScriptableObject
        Parameters:
        cx - the current Context
        key - the name/index of the property
        desc - the new property descriptor, as described in 8.6.1
      • getBuiltInDescriptor

        private ScriptableObject getBuiltInDescriptor​(java.lang.String name)
      • readObject

        private void readObject​(java.io.ObjectInputStream stream)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream stream)
                          throws java.io.IOException
        Throws:
        java.io.IOException