Search in sources :

Example 1 with PropertyDescriptor

use of org.mozilla.javascript.PropertyDescriptor in project scriptographer by scriptographer.

the class RhinoEngine method observe.

@Override
public boolean observe(Map object, Object key, PropertyObserver observer) {
    if (object instanceof ScriptableObject) {
        ScriptableObject obj = (ScriptableObject) object;
        Context cx = Context.getCurrentContext();
        PropertyDescriptor desc = obj.getOwnPropertyDescriptor(cx, key);
        if (desc != null && desc.isDataDescriptor()) {
            ObserverGetterSetter getterSetter = new ObserverGetterSetter(obj, key, desc, observer);
            obj.defineOwnProperty(cx, key, new PropertyDescriptor(getterSetter, getterSetter, desc.isEnumerable(), desc.isConfigurable(), true));
        }
        return true;
    }
    return false;
}
Also used : Context(org.mozilla.javascript.Context) ScriptableObject(org.mozilla.javascript.ScriptableObject) PropertyDescriptor(org.mozilla.javascript.PropertyDescriptor)

Aggregations

Context (org.mozilla.javascript.Context)1 PropertyDescriptor (org.mozilla.javascript.PropertyDescriptor)1 ScriptableObject (org.mozilla.javascript.ScriptableObject)1