Wrap function in Proxy for accessing remote properties
338944
function proxyFunctionProperties (remoteMemberFunction, metaId, name) {
  let loaded = false

  // Lazily load function properties
  const loadRemoteProperties = () => {
    if (loaded) return
    loaded = true
    const command = 'ELECTRON_BROWSER_MEMBER_GET'
    const meta = ipcRendererInternal.sendSync(command, contextId, metaId, name)
    setObjectMembers(remoteMemberFunction, remoteMemberFunction, meta.id, meta.members)
  }

  return new Proxy(remoteMemberFunction, {
    set: (target, property, value, receiver) => {
      if (property !== 'ref') loadRemoteProperties()
      target[property] = value
      return true
    },
    get: (target, property, receiver) => {
      if (!target.hasOwnProperty(property)) loadRemoteProperties()
      const value = target[property]
      if (property === 'toString' && typeof value === 'function') {
        return value.bind(target)
      }
      return value
    },
    ownKeys: (target) => {
      loadRemoteProperties()
      return Object.getOwnPropertyNames(target)
    },
    getOwnPropertyDescriptor: (target, property) => {
      const descriptor = Object.getOwnPropertyDescriptor(target, property)
      if (descriptor) return descriptor
      loadRemoteProperties()
      return Object.getOwnPropertyDescriptor(target, property)
    }
  })
}
1276319
function initApiProxy() {
  if (build.verbose)
    console.log('Proxying paths...');
  lodash.forEach(build.proxyMap, function (proxyOpts, urlPath) {
    if (build.verbose)
      console.log('  - url: "' + urlPath + '"');
    app.use(urlPath, proxy(proxyOpts));
    // e.g. `app.use('/api', proxy({target: "http://localhost:4321/api", 
    // changeOrigin: true});`
  });
}
201697
def call_and_wrap(func, *args, **kw):
    '''
    '''
    try:
        return func(*args, **kw)
    except api.exceptions.APIException as ex:
        click_exception(ex)
    except urllib3exc.SSLError:
        # see monkey patch above re InsecurePlatformWarning
        if _insecure_warning:
            click.echo(click.style(str(_insecure_warning[0]), fg='red'))
        raise
1294401
function makeProxy(object) {
    if (((typeof(object) === 'object') && (!Array.isArray(object))) ||
        (typeof(object) === 'function')) {

      /* Only non-array objects and functions get proxied */
      var proxyId = messages.addProxy(object);
      var definition = defineProxy(object);
      return { proxy: { id: proxyId, definition: definition }};

    } else {

      /* Arrays and normal objects go through as values */
      return { resolve: object };
    }
  }
227504
function wrap(callback, name) {
  var isLST
    , stack
    , d
    , oldStack

  if ('function' !== typeof callback || callback && callback.name === '_trycatchOnError') return callback

  isLST = options['long-stack-traces']
  d = process.domain
  if (isLST) {
    oldStack = trycatch.currentStack
    stack = getUpdatedCurrentStack()
  }

  // Inherit from callback for when properties are added
  _trycatchNewCallback.__proto__ = callback
  _trycatchNewCallback._trycatchCurrentStack = stack
  return _trycatchNewCallback

  function _trycatchNewCallback() {
    // Don't stomp stack in synchronous EventEmitter case
    if (isLST) {
      if (trycatch.currentStack !== oldStack) {
        trycatch.currentStack = stack
      } else if (trycatch.currentStack !== null) {
        trycatch.currentStack = stack
      }
    }
    runInDomain(d, callback, trycatchit, this, arguments)
  }
}
190106
protected T handleRealize(T proxy)
	{
		T ret = createInstance(proxy);
		PropertyResolverConverter prc = getPropertyResolverConverter();
		for (Map.Entry<String, Object> entry: values.entrySet()) {
			String propertyName = entry.getKey();
			Object value = entry.getValue();
			int mappedIndicatorIndx = propertyName.indexOf(':');
			if(mappedIndicatorIndx<0)
			{
				try
				{
					PropertyResolver.setValue(propertyName, ret, value, prc);
				} catch (WicketRuntimeException e)
				{
					LOG.error("Can't set property"+propertyName, e);
				}
			}
			else
			{
				String propertyExp = propertyName.substring(0, mappedIndicatorIndx);
				String fieldExp = propertyName.substring(mappedIndicatorIndx+1);
				Object object = ret;
				int subObject = propertyExp.lastIndexOf('.');
				if(subObject>=0)
				{
					object = PropertyResolver.getValue(propertyExp.substring(0, subObject), object);
					propertyExp = propertyExp.substring(subObject+1);
				}
				if(object!=null)
				{
					String methodName="set"+propertyExp.substring(0, 1).toUpperCase()+propertyExp.substring(1);
					Method[] methods = object.getClass().getMethods();
					try
					{
						for (Method method : methods)
						{
							if(method.getName().equals(methodName))
							{
								Class<?>[] paramTypes = method.getParameterTypes();
								if(paramTypes.length==2 
										&& paramTypes[0].isAssignableFrom(String.class)
										&& (value==null || paramTypes[1].isInstance(value)))
								{
									method.invoke(object, fieldExp, value);
									break;
								}
							}
						}
					} catch (Exception e)
					{
						LOG.error("Can't set property "+propertyName, e);
					} 
					
				}
			}
		}
		realized = ret;
		if(listener!=null) listener.onRealizePrototype((IPrototype<T>)proxy);
		return ret;
	}
1219067
def remote_eval(self, func, *args, **kwargs):
        
        return eval(self.remote(func, *args, **kwargs))
1062178
function ImmutableAI (args) {
    // object that will store the state of the call which must be constructed
    // through multiple proxied property gets
    var call = {
        session: args.session,
    }
    // the proxy object must be addressed first as a property get in order
    // to set the namespace, module, and method to be called and then
    // called as a function to call that method
    var proxyFunctionWrapper = function proxyFunctionWrapper (args) {
        // make call
        return proxyFunction(call, args)
    }
    // create proxy for the proxy function object that will intercept each
    // property access on that object
    call.proxy = new Proxy(proxyFunctionWrapper, {
        // call the get proxy handler with the current call state
        get: function getProxyWrapper (target, property) {
            return getProxy(call, property)
        },
        // call the set proxy handler with the current call state
        set: function setProxyWrapper (target, property, value) {
            return setProxy(call, property, value)
        },
    })
    // return proxied function object
    return call.proxy
}
403630
function(proxies, namespace, serverType, proxy) {
  proxies[namespace] = proxies[namespace] || {};
  if (proxies[namespace][serverType]) {
    for (let attr in proxy) {
      proxies[namespace][serverType][attr] = proxy[attr];
    }
  } else {
    proxies[namespace][serverType] = proxy;
  }
}
866201
def deprecate_module_with_proxy(module_name, module_dict, deprecated_attributes=None):
    
    def _ModuleProxy(module, depr):
        """Return a wrapped object that warns about deprecated accesses"""
        # http://stackoverflow.com/a/922693/2127762
        class Wrapper(object):
            def __getattr__(self, attr):
                if depr is None or attr in depr:
                    warnings.warn("Property %s is deprecated" % attr)

                return getattr(module, attr)

            def __setattr__(self, attr, value):
                if depr is None or attr in depr:
                    warnings.warn("Property %s is deprecated" % attr)
                return setattr(module, attr, value)
        return Wrapper()

    deprecated_import(module_name)

    deprs = set()
    for key in deprecated_attributes or module_dict:
        if key.startswith('_'):
            continue
        if callable(module_dict[key]) and not isbuiltin(module_dict[key]):
            module_dict[key] = deprecated(module_dict[key])
        else:
            deprs.add(key)
    sys.modules[module_name] = _ModuleProxy(sys.modules[module_name], deprs or None)
1275865
def proxy(self):
        """"""
        d = Deferred(self.loop)
        self._proxy_deferreds.append(d)

        if self._proxy:
            d.callback(self._proxy)

        return d
1112333
def wrap_requests(requests_func):
    """"""
    def call(url, *args, **kwargs):
        blacklist_hostnames = execution_context.get_opencensus_attr(
            'blacklist_hostnames')
        parsed_url = urlparse(url)
        if parsed_url.port is None:
            dest_url = parsed_url.hostname
        else:
            dest_url = '{}:{}'.format(parsed_url.hostname, parsed_url.port)
        if utils.disable_tracing_hostname(dest_url, blacklist_hostnames):
            return requests_func(url, *args, **kwargs)

        _tracer = execution_context.get_opencensus_tracer()
        _span = _tracer.start_span()
        _span.name = '[requests]{}'.format(requests_func.__name__)
        _span.span_kind = span_module.SpanKind.CLIENT

        # Add the requests url to attributes
        _tracer.add_attribute_to_current_span(HTTP_URL, url)

        result = requests_func(url, *args, **kwargs)

        # Add the status code to attributes
        _tracer.add_attribute_to_current_span(
            HTTP_STATUS_CODE, str(result.status_code))

        _tracer.end_span()
        return result

    return call
47354
function proxyProperty(name) {
    self.__defineGetter__(name, function(){
      return self._native[name];
    });
    self.__defineSetter__(name, function(val){
      self._native[name] = val;
    });
  }
323878
def _remote(self,
                args=None,
                kwargs=None,
                num_return_vals=None,
                num_cpus=None,
                num_gpus=None,
                resources=None):
        """"""
        worker = ray.worker.get_global_worker()
        worker.check_connected()

        if self._last_export_session < worker._session_index:
            # If this function was exported in a previous session, we need to
            # export this function again, because current GCS doesn't have it.
            self._last_export_session = worker._session_index
            worker.function_actor_manager.export(self)

        kwargs = {} if kwargs is None else kwargs
        args = [] if args is None else args
        args = ray.signature.extend_args(self._function_signature, args,
                                         kwargs)

        if num_return_vals is None:
            num_return_vals = self._num_return_vals

        resources = ray.utils.resources_from_resource_arguments(
            self._num_cpus, self._num_gpus, self._resources, num_cpus,
            num_gpus, resources)
        if worker.mode == ray.worker.LOCAL_MODE:
            # In LOCAL_MODE, remote calls simply execute the function.
            # We copy the arguments to prevent the function call from
            # mutating them and to match the usual behavior of
            # immutable remote objects.
            result = self._function(*copy.deepcopy(args))
            return result
        object_ids = worker.submit_task(
            self._function_descriptor,
            args,
            num_return_vals=num_return_vals,
            resources=resources)
        if len(object_ids) == 1:
            return object_ids[0]
        elif len(object_ids) > 1:
            return object_ids
1069692
function mixinProxying(agent, proxyOpts) {
  agent.proxy = proxyOpts;

  var orig = _.pick(agent, 'createConnection', 'addRequest');

  // Make the tcp or tls connection go to the proxy, ignoring the
  // destination host:port arguments.
  agent.createConnection = function(port, host, options) {
    return orig.createConnection.call(this,
                                      this.proxy.port, this.proxy.host, options);
  };

  // tell the proxy where we really want to go by fully-qualifying the path
  // part. Force a localAddress if one was configured
  agent.addRequest = function(req, host, port, localAddress) {
    req.path = this.proxy.innerProtocol + '//' + host + ':' + port + req.path;
    if (this.proxy.localAddress) {
      localAddress = this.proxy.localAddress;
    }
    return orig.addRequest.call(this, req, host, port, localAddress);
  };
}
337313
function proxyFunction (call, args) {
    // get clone of call and reset original
    call = resetCall(call)
    // require immutable core
    assert.ok(GLOBAL.immutableCore !== undefined, 'ImmutableAI configuration error: immutableCore required')
    // require call properties
    assert.ok(call.namespace !== undefined, 'ImmutableAI method call without namespace')
    assert.ok(call.module !== undefined, 'ImmutableAI method call without module name')
    assert.ok(call.method !== undefined, 'ImmutableAI method call without method name')
    // create method signature
    var signature = call.module+GLOBAL.localNamespaces[call.namespace]+'.'+call.method
    // get method - throws error if not found
    var method = GLOBAL.immutableCore.method(signature)
    // create empty object for args if not defined
    if (args === undefined) {
        args = {}
    }
    // set session for args
    args.session = call.session
    // call method with args and session
    return method(args)
}
762302
function findProxyObject(uri, proxyName, callback) {
    var proxyObject = {},
        folderUri = path.join(uri, proxyName)

    iterateFiles(folderUri, function (fileName) {
        var relativePropertyName = path.relative(folderUri, fileName),
            relativeValue = path.relative(uri, fileName)

        relativePropertyName = relativePropertyName.replace(isFile, "")
        var props = relativePropertyName.split("/")

        props.reduce(function (memo, value, index) {
            if (index === props.length - 1) {
                memo[value] = relativeValue
            } else {
                return (memo[value] = memo[value] || {})
            }
        }, proxyObject)

    }, function (err) {
        callback(err, proxyObject)
    })

    //fs.readdir(folderUri, mapIntoProxyObject)

    function mapIntoProxyObject(err, files) {
        if (err) {
            return callback(err)
        }
        files.filter(isFileFunction).forEach(addToProxyObject)
        callback(null, proxyObject)
    }

    function addToProxyObject(fileName) {
        var propertyName = fileName.replace(isFile, "")

        proxyObject[propertyName] = 
            path.join(proxyName, fileName)
    }
}