From f70fa989547a256255ae74264ac6e906709b72f4 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 24 Aug 2016 15:29:12 +0200 Subject: Make has_property_on_prototype fallible --- .../script/dom/bindings/codegen/CodegenRust.py | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'components/script/dom/bindings/codegen/CodegenRust.py') diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 8e04fc76a10..4eb02f796e0 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -4724,10 +4724,17 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): # Once we start supporting OverrideBuiltins we need to make # ResolveOwnProperty or EnumerateOwnProperties filter out named # properties that shadow prototype properties. - namedGet = ("\n" + - "if RUST_JSID_IS_STRING(id) && !has_property_on_prototype(cx, proxy, id) {\n" + - CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" + - "}\n") + namedGet = """ +if RUST_JSID_IS_STRING(id) { + let mut has_on_proto = false; + if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) { + return false; + } + if !has_on_proto { + %s + } +} +""" % CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues), 8).define() else: namedGet = "" @@ -4952,12 +4959,20 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod): namedGetter = self.descriptor.operations['NamedGetter'] if namedGetter: - named = ("if RUST_JSID_IS_STRING(id) && !has_property_on_prototype(cx, proxy, id) {\n" + - CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" + - " *bp = found;\n" - " return true;\n" - "}\n" + - "\n") + named = """\ +if RUST_JSID_IS_STRING(id) { + let mut has_on_proto = false; + if !has_property_on_prototype(cx, proxy, id, &mut has_on_proto) { + return false; + } + if !has_on_proto { + %s + *bp = found; + return true; + } +} + +""" % CGIndenter(CGProxyNamedGetter(self.descriptor), 8).define() else: named = "" -- cgit v1.2.3 From 6c1167b1e2ec6939f88878aa21eebaab7dbe547e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 24 Aug 2016 15:34:35 +0200 Subject: Pass the receiver to get_property_on_prototype (fixes #11600) --- components/script/dom/bindings/codegen/CodegenRust.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'components/script/dom/bindings/codegen/CodegenRust.py') diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 4eb02f796e0..643262c0db2 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -5050,7 +5050,7 @@ if !expando.is_null() { %s let mut found = false; -if !get_property_on_prototype(cx, proxy, id, &mut found, vp) { +if !get_property_on_prototype(cx, proxy, receiver, id, &mut found, vp) { return false; } -- cgit v1.2.3