aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2015-12-25 04:56:45 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2016-02-23 17:23:51 +0100
commit7f36247d031f9533de7e06a9aae3f4931dd59c67 (patch)
tree84e7bc95356af5e7915705feab2947141bfe3d7b /components/script/dom/bindings/codegen/CodegenRust.py
parentcbf514d63fb4f48c62af776b65d21dc0e4ad9bde (diff)
downloadservo-7f36247d031f9533de7e06a9aae3f4931dd59c67.tar.gz
servo-7f36247d031f9533de7e06a9aae3f4931dd59c67.zip
Support [LegacyUnenumerableNamedProperties]
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py82
1 files changed, 72 insertions, 10 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 62145bd60e8..6d626bea0ca 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2602,13 +2602,25 @@ class CGDefineProxyHandler(CGAbstractMethod):
if self.descriptor.operations['NamedDeleter']:
customDelete = 'delete'
- body = """\
+ getOwnEnumerablePropertyKeys = "None"
+ if self.descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
+ getOwnEnumerablePropertyKeys = "Some(getOwnEnumerablePropertyKeys)"
+
+ args = {
+ "defineProperty": customDefineProperty,
+ "delete": customDelete,
+ "getOwnEnumerablePropertyKeys": getOwnEnumerablePropertyKeys,
+ "trace": TRACE_HOOK_NAME,
+ "finalize": FINALIZE_HOOK_NAME,
+ }
+
+ return CGGeneric("""\
let traps = ProxyTraps {
enter: None,
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
- defineProperty: Some(%s),
+ defineProperty: Some(%(defineProperty)s),
ownPropertyKeys: Some(own_property_keys),
- delete_: Some(%s),
+ delete_: Some(%(delete)s),
enumerate: None,
preventExtensions: Some(proxyhandler::prevent_extensions),
isExtensible: Some(proxyhandler::is_extensible),
@@ -2619,7 +2631,7 @@ let traps = ProxyTraps {
construct: None,
getPropertyDescriptor: Some(get_property_descriptor),
hasOwn: Some(hasOwn),
- getOwnEnumerablePropertyKeys: None,
+ getOwnEnumerablePropertyKeys: %(getOwnEnumerablePropertyKeys)s,
nativeCall: None,
hasInstance: None,
objectClassIs: None,
@@ -2627,16 +2639,15 @@ let traps = ProxyTraps {
fun_toString: None,
boxedValue_unbox: None,
defaultValue: None,
- trace: Some(%s),
- finalize: Some(%s),
+ trace: Some(%(trace)s),
+ finalize: Some(%(finalize)s),
objectMoved: None,
isCallable: None,
isConstructor: None,
};
CreateProxyHandler(&traps, &Class as *const _ as *const _)\
-""" % (customDefineProperty, customDelete, TRACE_HOOK_NAME, FINALIZE_HOOK_NAME)
- return CGGeneric(body)
+""" % args)
class CGDefineDOMInterfaceMethod(CGAbstractMethod):
@@ -4340,9 +4351,15 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
namedGetter = self.descriptor.operations['NamedGetter']
if namedGetter:
- attrs = "JSPROP_ENUMERATE"
+ attrs = []
+ if not self.descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
+ attrs.append("JSPROP_ENUMERATE")
if self.descriptor.operations['NamedSetter'] is None:
- attrs += " | JSPROP_READONLY"
+ attrs.append("JSPROP_READONLY")
+ if attrs:
+ attrs = " | ".join(attrs)
+ else:
+ attrs = "0"
fillDescriptor = ("desc.get().value = result_root.ptr;\n"
"fill_property_descriptor(&mut *desc.ptr, *proxy.ptr, %s);\n"
"return true;" % attrs)
@@ -4518,6 +4535,49 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
return CGGeneric(self.getBody())
+class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
+ def __init__(self, descriptor):
+ assert (descriptor.operations["IndexedGetter"] and
+ descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
+ args = [Argument('*mut JSContext', 'cx'),
+ Argument('HandleObject', 'proxy'),
+ Argument('*mut AutoIdVector', 'props')]
+ CGAbstractExternMethod.__init__(self, descriptor,
+ "getOwnEnumerablePropertyKeys", "bool", args)
+ self.descriptor = descriptor
+
+ def getBody(self):
+ body = dedent(
+ """
+ let unwrapped_proxy = UnwrapProxy(proxy);
+ """)
+
+ if self.descriptor.operations['IndexedGetter']:
+ body += dedent(
+ """
+ for i in 0..(*unwrapped_proxy).Length() {
+ let rooted_jsid = RootedId::new(cx, int_to_jsid(i as i32));
+ AppendToAutoIdVector(props, rooted_jsid.handle().get());
+ }
+ """)
+
+ body += dedent(
+ """
+ let expando = get_expando_object(proxy);
+ if !expando.is_null() {
+ let rooted_expando = RootedObject::new(cx, expando);
+ GetPropertyKeys(cx, rooted_expando.handle(), JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, props);
+ }
+
+ return true;
+ """)
+
+ return body
+
+ def definition_body(self):
+ return CGGeneric(self.getBody())
+
+
class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
def __init__(self, descriptor):
args = [Argument('*mut JSContext', 'cx'), Argument('HandleObject', 'proxy'),
@@ -4967,6 +5027,8 @@ class CGDescriptor(CGThing):
cgThings.append(CGProxyUnwrap(descriptor))
cgThings.append(CGDOMJSProxyHandlerDOMClass(descriptor))
cgThings.append(CGDOMJSProxyHandler_ownPropertyKeys(descriptor))
+ if descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
+ cgThings.append(CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(descriptor))
cgThings.append(CGDOMJSProxyHandler_getOwnPropertyDescriptor(descriptor))
cgThings.append(CGDOMJSProxyHandler_className(descriptor))
cgThings.append(CGDOMJSProxyHandler_get(descriptor))