More in depth, here's a concept for separating Virtualization from Notification:
Assumes: using the same list of traps as Direct Proxies, a proxy has internal [[Target]] and [[Handler]] properties, proxy.[[IsExtensible]] and proxy.[[GetInheritance]] forward to the target. TrapVirtual(proxy, trap, args): dispatches to GetTrap(proxy.[[ProxyHandler]], trap) and uses the return value to fulfill the original request TrapNotify(proxy, trap, args): dispatches to GetTrap(proxy.[[ProxyHandler]], trap) disregards the result, and then forward the request to proxy.[[ProxyTarget]] returning that result IsPropertyFrozen(proxy, property): returns true if property is in proxy.[[ProxyTarget]].[[FrozenProperties]]. Otherwise false. A Notifier Proxy uses TrapNotify for all traps and does not have any additional state. A Virtual Object is a kind of dummy object that is used for Virtual Proxies. When created, it takes on the internal properties of the given target and additionally shallow clones all the properties. If the target is a proxy itself, then the internal methods it takes are from the [[ProxyTarget]] (recursively until hitting a real object). It does not otherwise keep a reference or any relation to the target. A Virtual Object has an additional internal property [[FrozenProperties]] which is a list of property names that are non-configurable. The [[DefineOwnProperty]] method of a Virtual Object invokes the [[DefineOwnProperty]] method taken from the target, and additionally adds the property to its [[FrozenProperties]] if a property becomes non-configurable. A Virtual Proxy is a proxy that conditionally uses TrapNotify or TrapVirtual and who's target is a new Virtual Object created from the provided target. Whether TrapNotify or TrapVirtual is used is determined by the following set of rules: When virtualproxy.[[IsExtensible]]() is true: * TrapVirtual is used for 'getOwnPropertyNames', 'enumerate', and 'keys'. The return is modified to ensure every name in virtualproxy.[[ProxyTarget]].[[FrozenProperties]]. is included. * For 'deleteProperty', 'hasOwnProperty', and 'set', if IsPropertyFrozen(virtualproxy, property) is true TrapNotify is used. Otherwise TrapVirtual is used. * For 'defineProperty', if the provided descriptor has 'configurable' set to false,or if IsPropertyFrozen(virtualproxy, property) is true then TrapNotify is used, otherwise TrapVirtual is used. * For 'getOwnPropertyDescriptor', if IsPropertyFrozen(virtualproxy, property) is true then TrapNotify is used. Otherwise TrapVirtual is used and if the result has 'configurable' set to false, the property is defined on virtualproxy.[[ProxyTarget]]. * For 'get' if IsPropertyFrozen(virtualproxy, property) is true then TrapNotify is used. Otherwise TrapVirtual is used. When virtualproxy.[[IsExtensible]]() is false: * TrapNotify is used for 'getOwnPropertyNames', 'enumerate', 'keys', 'deleteProperty', 'hasOwnProperty' * For 'defineProperty' and 'set', if the property does not exist in virtualproxy.[[ProxyTarget]] or if IsPropertyFrozen(virtualproxy, property) is true then TrapNotify is used. Otherwise TrapVirtual is used. * For 'getOwnPropertyDescriptor', if the property does not exist in virtualproxy.[[ProxyTarget]] or if IsPropertyFrozen(virtualproxy, property) then TrapNotify is used. Otherwise TrapVirtual is used and if the result has 'configurable' set to false, the property is defined on virtualproxy.[[ProxyTarget]]. * For 'get', if the property does not exist in virtualproxy.[[ProxyTarget]] or if IsPropertyFrozen(virtualproxy, property) then TrapNotify is used. Otherwise TrapVirtual is used. On Sun, Nov 25, 2012 at 7:15 AM, Brandon Benvie <[email protected]>wrote: > I think it could be argued that the two categories of proxy uses have > different enough fundamentals that they would be better suited broken into > two separate types of proxies. They use a common protocol for dispatching > notifications/requests, but the result is incompatible. > > For a Notification Proxy the trap is notified and then action proceeds > against the ProxyTarget as it would normally. This is the simple case since > it merely adds a pre-notification to the front of all trapped operations > and nothing else changes. > > For a Virtual Proxy the invariant-sensitive attributes of the virtual > target act like those of a Notification Proxy. Any time something becomes > invariant, whether it be a property or the whole object, the value is > reified from being virtual to being an actual property. From that point on > the property or the whole Proxy changes behavior from Virtual to > Notification. >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

