aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-04-28 07:51:31 -0500
committerbors-servo <metajack+bors@gmail.com>2015-04-28 07:51:31 -0500
commit01925f0f8f65be177e0c2d9bab14b091bf67b220 (patch)
tree51b29f60908ccc0434b0ba0e089e652e80cde036 /components/script/dom/bindings/codegen/CodegenRust.py
parent2fd5ecf3d7b93addb42d42d46e440451043a2f43 (diff)
parentcdcd6670ba39be3cbaffb154f876b052b6ecdc51 (diff)
downloadservo-01925f0f8f65be177e0c2d9bab14b091bf67b220.tar.gz
servo-01925f0f8f65be177e0c2d9bab14b091bf67b220.zip
Auto merge of #5845 - snf:defineProperty_fix, r=jdm
This patch should get rid of #5223. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5845) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py45
1 files changed, 31 insertions, 14 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 6b4acd64bd4..b48efbda91d 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -3745,6 +3745,14 @@ class CGProxyNamedGetter(CGProxySpecialOperation):
self.templateValues = templateValues
CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter')
+class CGProxyNamedPresenceChecker(CGProxyNamedGetter):
+ """
+ Class to generate a call that checks whether a named property exists.
+ For now, we just delegate to CGProxyNamedGetter
+ """
+ def __init__(self, descriptor):
+ CGProxyNamedGetter.__init__(self, descriptor)
+
class CGProxyNamedSetter(CGProxySpecialOperation):
"""
Class to generate a call to a named setter.
@@ -3872,6 +3880,7 @@ return true;"""
def definition_body(self):
return CGGeneric(self.getBody())
+# TODO(Issue 5876)
class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
def __init__(self, descriptor):
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
@@ -3911,21 +3920,29 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
" let this = Unrooted::from_raw(this);\n" +
" let this = this.root();\n" +
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
+ " return true;\n" +
+ "} else {\n" +
+ " return false;\n" +
"}\n")
- elif self.descriptor.operations['NamedGetter']:
- set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
- " let name = jsid_to_str(cx, id);\n" +
- " let this = UnwrapProxy(proxy);\n" +
- " let this = Unrooted::from_raw(this);\n" +
- " let this = this.root();\n" +
- CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
- " if (found) {\n"
- " return false;\n" +
- " //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
- " }\n" +
- " return true;\n"
- "}\n") % (self.descriptor.name)
- return set + """return proxyhandler::define_property(%s);""" % ", ".join(a.name for a in self.args)
+ else:
+ if self.descriptor.operations['NamedGetter']:
+ set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
+ " let name = jsid_to_str(cx, id);\n" +
+ " let this = UnwrapProxy(proxy);\n" +
+ " let this = Unrooted::from_raw(this);\n" +
+ " let this = this.root();\n" +
+ CGProxyNamedPresenceChecker(self.descriptor).define() +
+ " if (found) {\n" +
+ # TODO(Issue 5876)
+ " //return js::IsInNonStrictPropertySet(cx)\n" +
+ " // ? opresult.succeed()\n" +
+ " // : ThrowErrorMessage(cx, MSG_NO_NAMED_SETTER, \"${name}\");\n" +
+ " return true;\n" +
+ " }\n" +
+ "}"
+ ) % (self.descriptor.name, self.descriptor.name)
+ set += "return proxyhandler::define_property(%s);" % ", ".join(a.name for a in self.args)
+ return set
def definition_body(self):
return CGGeneric(self.getBody())