mirror of
https://github.com/servo/servo.git
synced 2025-07-25 08:10:21 +01:00
Auto merge of #7387 - Yoric:2240-2, r=Ms2ger
Fixes #2240 - NamedGetter and NamedSetter do not assume that the arg is named `name` I'm not totally sure about how to test this. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7387) <!-- Reviewable:end -->
This commit is contained in:
commit
a897795dab
2 changed files with 31 additions and 24 deletions
|
@ -3966,7 +3966,23 @@ class CGProxyIndexedSetter(CGProxySpecialOperation):
|
||||||
CGProxySpecialOperation.__init__(self, descriptor, 'IndexedSetter')
|
CGProxySpecialOperation.__init__(self, descriptor, 'IndexedSetter')
|
||||||
|
|
||||||
|
|
||||||
class CGProxyNamedGetter(CGProxySpecialOperation):
|
class CGProxyNamedOperation(CGProxySpecialOperation):
|
||||||
|
"""
|
||||||
|
Class to generate a call to a named operation.
|
||||||
|
"""
|
||||||
|
def __init__(self, descriptor, name):
|
||||||
|
CGProxySpecialOperation.__init__(self, descriptor, name)
|
||||||
|
|
||||||
|
def define(self):
|
||||||
|
# Our first argument is the id we're getting.
|
||||||
|
argName = self.arguments[0].identifier.name
|
||||||
|
return ("let %s = jsid_to_str(cx, id);\n"
|
||||||
|
"let this = UnwrapProxy(proxy);\n"
|
||||||
|
"let this = &*this;\n" % argName +
|
||||||
|
CGProxySpecialOperation.define(self))
|
||||||
|
|
||||||
|
|
||||||
|
class CGProxyNamedGetter(CGProxyNamedOperation):
|
||||||
"""
|
"""
|
||||||
Class to generate a call to an named getter. If templateValues is not None
|
Class to generate a call to an named getter. If templateValues is not None
|
||||||
the returned value will be wrapped with wrapForType using templateValues.
|
the returned value will be wrapped with wrapForType using templateValues.
|
||||||
|
@ -3976,7 +3992,16 @@ class CGProxyNamedGetter(CGProxySpecialOperation):
|
||||||
CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter')
|
CGProxySpecialOperation.__init__(self, descriptor, 'NamedGetter')
|
||||||
|
|
||||||
|
|
||||||
class CGProxyNamedSetter(CGProxySpecialOperation):
|
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(CGProxyNamedOperation):
|
||||||
"""
|
"""
|
||||||
Class to generate a call to a named setter.
|
Class to generate a call to a named setter.
|
||||||
"""
|
"""
|
||||||
|
@ -3984,7 +4009,7 @@ class CGProxyNamedSetter(CGProxySpecialOperation):
|
||||||
CGProxySpecialOperation.__init__(self, descriptor, 'NamedSetter')
|
CGProxySpecialOperation.__init__(self, descriptor, 'NamedSetter')
|
||||||
|
|
||||||
|
|
||||||
class CGProxyNamedDeleter(CGProxySpecialOperation):
|
class CGProxyNamedDeleter(CGProxyNamedOperation):
|
||||||
"""
|
"""
|
||||||
Class to generate a call to a named deleter.
|
Class to generate a call to a named deleter.
|
||||||
"""
|
"""
|
||||||
|
@ -4057,9 +4082,6 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
# properties that shadow prototype properties.
|
# properties that shadow prototype properties.
|
||||||
namedGet = ("\n" +
|
namedGet = ("\n" +
|
||||||
"if RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" +
|
"if RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" +
|
||||||
" let name = jsid_to_str(cx, id);\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
|
||||||
" let this = &*this;\n" +
|
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" +
|
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() + "\n" +
|
||||||
"}\n")
|
"}\n")
|
||||||
else:
|
else:
|
||||||
|
@ -4121,9 +4143,6 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
if not self.descriptor.operations['NamedCreator'] is namedSetter:
|
if not self.descriptor.operations['NamedCreator'] is namedSetter:
|
||||||
raise TypeError("Can't handle creator that's different from the setter")
|
raise TypeError("Can't handle creator that's different from the setter")
|
||||||
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
||||||
" let name = jsid_to_str(cx, id);\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
|
||||||
" let this = &*this;\n" +
|
|
||||||
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
CGIndenter(CGProxyNamedSetter(self.descriptor)).define() +
|
||||||
" (*opresult).code_ = 0; /* SpecialCodes::OkCode */\n" +
|
" (*opresult).code_ = 0; /* SpecialCodes::OkCode */\n" +
|
||||||
" return JSTrue;\n" +
|
" return JSTrue;\n" +
|
||||||
|
@ -4132,9 +4151,6 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
"}\n")
|
"}\n")
|
||||||
else:
|
else:
|
||||||
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
||||||
" let name = jsid_to_str(cx, id);\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
|
||||||
" let this = &*this;\n" +
|
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
||||||
" if (found) {\n"
|
" if (found) {\n"
|
||||||
# TODO(Issue 5876)
|
# TODO(Issue 5876)
|
||||||
|
@ -4165,10 +4181,7 @@ class CGDOMJSProxyHandler_delete(CGAbstractExternMethod):
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
set = ""
|
set = ""
|
||||||
if self.descriptor.operations['NamedDeleter']:
|
if self.descriptor.operations['NamedDeleter']:
|
||||||
set += ("let name = jsid_to_str(cx, id);\n" +
|
set += CGProxyNamedDeleter(self.descriptor).define()
|
||||||
"let this = UnwrapProxy(proxy);\n" +
|
|
||||||
"let this = &*this;\n" +
|
|
||||||
"%s") % (CGProxyNamedDeleter(self.descriptor).define())
|
|
||||||
set += "return proxyhandler::delete(%s) as u8;" % ", ".join(a.name for a in self.args)
|
set += "return proxyhandler::delete(%s) as u8;" % ", ".join(a.name for a in self.args)
|
||||||
return set
|
return set
|
||||||
|
|
||||||
|
@ -4253,9 +4266,6 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
named = ("if RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" +
|
named = ("if RUST_JSID_IS_STRING(id) != 0 && !has_property_on_prototype(cx, proxy, id) {\n" +
|
||||||
" let name = jsid_to_str(cx, id);\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
|
||||||
" let this = &*this;\n" +
|
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" +
|
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" +
|
||||||
" *bp = found as u8;\n"
|
" *bp = found as u8;\n"
|
||||||
" return JSTrue;\n"
|
" return JSTrue;\n"
|
||||||
|
@ -4329,9 +4339,6 @@ if !expando.ptr.is_null() {
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
getNamed = ("if (RUST_JSID_IS_STRING(id) != 0) {\n" +
|
getNamed = ("if (RUST_JSID_IS_STRING(id) != 0) {\n" +
|
||||||
" let name = jsid_to_str(cx, id);\n" +
|
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
|
||||||
" let this = &*this;\n" +
|
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
||||||
"}\n")
|
"}\n")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
interface TestBindingProxy : TestBinding {
|
interface TestBindingProxy : TestBinding {
|
||||||
readonly attribute unsigned long length;
|
readonly attribute unsigned long length;
|
||||||
|
|
||||||
getter DOMString getNamedItem(DOMString name);
|
getter DOMString getNamedItem(DOMString item_name);
|
||||||
|
|
||||||
setter creator void setNamedItem(DOMString name, DOMString value);
|
setter creator void setNamedItem(DOMString item_name, DOMString value);
|
||||||
|
|
||||||
getter DOMString getItem(unsigned long index);
|
getter DOMString getItem(unsigned long index);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue