Java 类jdk.nashorn.internal.runtime.AccessorProperty 实例源码

项目:OpenJSharp    文件:NativeObject.java   
/**
 * Binds the source mirror object's properties to the target object. Binding
 * properties allows two-way read/write for the properties of the source object.
 * All inherited, enumerable properties are also bound. This method is used to
 * to make 'with' statement work with ScriptObjectMirror as scope object.
 *
 * @param target the target object to which the source object's properties are bound
 * @param source the source object whose properties are bound to the target
 * @return the target object after property binding
 */
public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) {
    final Set<String> keys = source.keySet();
    // make accessor properties using dynamic invoker getters and setters
    final AccessorProperty[] props = new AccessorProperty[keys.size()];
    int idx = 0;
    for (final String name : keys) {
        final MethodHandle getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getElem:" + name, MIRROR_GETTER_TYPE);
        final MethodHandle setter = Bootstrap.createDynamicInvoker("dyn:setProp|setElem:" + name, MIRROR_SETTER_TYPE);
        props[idx] = AccessorProperty.create(name, 0, getter, setter);
        idx++;
    }

    target.addBoundProperties(source, props);
    return target;
}
项目:kaziranga    文件:NativeObject.java   
/**
 * Binds the source mirror object's properties to the target object. Binding
 * properties allows two-way read/write for the properties of the source object.
 * All inherited, enumerable properties are also bound. This method is used to
 * to make 'with' statement work with ScriptObjectMirror as scope object.
 *
 * @param target the target object to which the source object's properties are bound
 * @param source the source object whose properties are bound to the target
 * @return the target object after property binding
 */
public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) {
    final Set<String> keys = source.keySet();
    // make accessor properties using dynamic invoker getters and setters
    final AccessorProperty[] props = new AccessorProperty[keys.size()];
    int idx = 0;
    for (final String name : keys) {
        final MethodHandle getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getElem:" + name, MIRROR_GETTER_TYPE);
        final MethodHandle setter = Bootstrap.createDynamicInvoker("dyn:setProp|setElem:" + name, MIRROR_SETTER_TYPE);
        props[idx] = AccessorProperty.create(name, 0, getter, setter);
        idx++;
    }

    target.addBoundProperties(source, props);
    return target;
}
项目:lookaside_java-1.8.0-openjdk    文件:NativeObject.java   
/**
 * Binds the source mirror object's properties to the target object. Binding
 * properties allows two-way read/write for the properties of the source object.
 * All inherited, enumerable properties are also bound. This method is used to
 * to make 'with' statement work with ScriptObjectMirror as scope object.
 *
 * @param target the target object to which the source object's properties are bound
 * @param source the source object whose properties are bound to the target
 * @return the target object after property binding
 */
public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) {
    final Set<String> keys = source.keySet();
    // make accessor properties using dynamic invoker getters and setters
    final AccessorProperty[] props = new AccessorProperty[keys.size()];
    int idx = 0;
    for (final String name : keys) {
        final MethodHandle getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getElem:" + name, MIRROR_GETTER_TYPE);
        final MethodHandle setter = Bootstrap.createDynamicInvoker("dyn:setProp|setElem:" + name, MIRROR_SETTER_TYPE);
        props[idx] = AccessorProperty.create(name, 0, getter, setter);
        idx++;
    }

    target.addBoundProperties(source, props);
    return target;
}
项目:jdk8u_nashorn    文件:NativeObject.java   
/**
 * Binds the source mirror object's properties to the target object. Binding
 * properties allows two-way read/write for the properties of the source object.
 * All inherited, enumerable properties are also bound. This method is used to
 * to make 'with' statement work with ScriptObjectMirror as scope object.
 *
 * @param target the target object to which the source object's properties are bound
 * @param source the source object whose properties are bound to the target
 * @return the target object after property binding
 */
public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) {
    final Set<String> keys = source.keySet();
    // make accessor properties using dynamic invoker getters and setters
    final AccessorProperty[] props = new AccessorProperty[keys.size()];
    int idx = 0;
    for (final String name : keys) {
        final MethodHandle getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getElem:" + name, MIRROR_GETTER_TYPE);
        final MethodHandle setter = Bootstrap.createDynamicInvoker("dyn:setProp|setElem:" + name, MIRROR_SETTER_TYPE);
        props[idx] = AccessorProperty.create(name, 0, getter, setter);
        idx++;
    }

    target.addBoundProperties(source, props);
    return target;
}
项目:infobip-open-jdk-8    文件:NativeObject.java   
/**
 * Binds the source mirror object's properties to the target object. Binding
 * properties allows two-way read/write for the properties of the source object.
 * All inherited, enumerable properties are also bound. This method is used to
 * to make 'with' statement work with ScriptObjectMirror as scope object.
 *
 * @param target the target object to which the source object's properties are bound
 * @param source the source object whose properties are bound to the target
 * @return the target object after property binding
 */
public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) {
    final Set<String> keys = source.keySet();
    // make accessor properties using dynamic invoker getters and setters
    final AccessorProperty[] props = new AccessorProperty[keys.size()];
    int idx = 0;
    for (final String name : keys) {
        final MethodHandle getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getElem:" + name, MIRROR_GETTER_TYPE);
        final MethodHandle setter = Bootstrap.createDynamicInvoker("dyn:setProp|setElem:" + name, MIRROR_SETTER_TYPE);
        props[idx] = AccessorProperty.create(name, 0, getter, setter);
        idx++;
    }

    target.addBoundProperties(source, props);
    return target;
}
项目:openjdk-jdk10    文件:NativeObject.java   
/**
 * Binds the source mirror object's properties to the target object. Binding
 * properties allows two-way read/write for the properties of the source object.
 * All inherited, enumerable properties are also bound. This method is used to
 * to make 'with' statement work with ScriptObjectMirror as scope object.
 *
 * @param target the target object to which the source object's properties are bound
 * @param source the source object whose properties are bound to the target
 * @return the target object after property binding
 */
public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) {
    final Set<String> keys = source.keySet();
    // make accessor properties using dynamic invoker getters and setters
    final AccessorProperty[] props = new AccessorProperty[keys.size()];
    int idx = 0;
    for (final String name : keys) {
        props[idx] = createAccessorProperty(name);
        idx++;
    }

    target.addBoundProperties(source, props);
    return target;
}
项目:openjdk9    文件:NativeObject.java   
/**
 * Binds the source mirror object's properties to the target object. Binding
 * properties allows two-way read/write for the properties of the source object.
 * All inherited, enumerable properties are also bound. This method is used to
 * to make 'with' statement work with ScriptObjectMirror as scope object.
 *
 * @param target the target object to which the source object's properties are bound
 * @param source the source object whose properties are bound to the target
 * @return the target object after property binding
 */
public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) {
    final Set<String> keys = source.keySet();
    // make accessor properties using dynamic invoker getters and setters
    final AccessorProperty[] props = new AccessorProperty[keys.size()];
    int idx = 0;
    for (final String name : keys) {
        props[idx] = createAccessorProperty(name);
        idx++;
    }

    target.addBoundProperties(source, props);
    return target;
}
项目:openjdk-jdk10    文件:NativeObject.java   
private static AccessorProperty createAccessorProperty(final String name) {
    final MethodHandle getter = Bootstrap.createDynamicInvoker(name, NashornCallSiteDescriptor.GET_METHOD_PROPERTY, MIRROR_GETTER_TYPE);
    final MethodHandle setter = Bootstrap.createDynamicInvoker(name, NashornCallSiteDescriptor.SET_PROPERTY, MIRROR_SETTER_TYPE);
    return AccessorProperty.create(name, 0, getter, setter);
}
项目:openjdk9    文件:NativeObject.java   
private static AccessorProperty createAccessorProperty(final String name) {
    final MethodHandle getter = Bootstrap.createDynamicInvoker(name, NashornCallSiteDescriptor.GET_METHOD_PROPERTY, MIRROR_GETTER_TYPE);
    final MethodHandle setter = Bootstrap.createDynamicInvoker(name, NashornCallSiteDescriptor.SET_PROPERTY, MIRROR_SETTER_TYPE);
    return AccessorProperty.create(name, 0, getter, setter);
}