mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +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')
|
||||
|
||||
|
||||
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
|
||||
the returned value will be wrapped with wrapForType using templateValues.
|
||||
|
@ -3976,7 +3992,16 @@ class CGProxyNamedGetter(CGProxySpecialOperation):
|
|||
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.
|
||||
"""
|
||||
|
@ -3984,7 +4009,7 @@ class CGProxyNamedSetter(CGProxySpecialOperation):
|
|||
CGProxySpecialOperation.__init__(self, descriptor, 'NamedSetter')
|
||||
|
||||
|
||||
class CGProxyNamedDeleter(CGProxySpecialOperation):
|
||||
class CGProxyNamedDeleter(CGProxyNamedOperation):
|
||||
"""
|
||||
Class to generate a call to a named deleter.
|
||||
"""
|
||||
|
@ -4057,9 +4082,6 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
|||
# properties that shadow prototype properties.
|
||||
namedGet = ("\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" +
|
||||
"}\n")
|
||||
else:
|
||||
|
@ -4121,9 +4143,6 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
if not self.descriptor.operations['NamedCreator'] is namedSetter:
|
||||
raise TypeError("Can't handle creator that's different from the setter")
|
||||
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() +
|
||||
" (*opresult).code_ = 0; /* SpecialCodes::OkCode */\n" +
|
||||
" return JSTrue;\n" +
|
||||
|
@ -4132,9 +4151,6 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
|||
"}\n")
|
||||
else:
|
||||
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() +
|
||||
" if (found) {\n"
|
||||
# TODO(Issue 5876)
|
||||
|
@ -4165,10 +4181,7 @@ class CGDOMJSProxyHandler_delete(CGAbstractExternMethod):
|
|||
def getBody(self):
|
||||
set = ""
|
||||
if self.descriptor.operations['NamedDeleter']:
|
||||
set += ("let name = jsid_to_str(cx, id);\n" +
|
||||
"let this = UnwrapProxy(proxy);\n" +
|
||||
"let this = &*this;\n" +
|
||||
"%s") % (CGProxyNamedDeleter(self.descriptor).define())
|
||||
set += CGProxyNamedDeleter(self.descriptor).define()
|
||||
set += "return proxyhandler::delete(%s) as u8;" % ", ".join(a.name for a in self.args)
|
||||
return set
|
||||
|
||||
|
@ -4253,9 +4266,6 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
|||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
if namedGetter:
|
||||
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" +
|
||||
" *bp = found as u8;\n"
|
||||
" return JSTrue;\n"
|
||||
|
@ -4329,9 +4339,6 @@ if !expando.ptr.is_null() {
|
|||
namedGetter = self.descriptor.operations['NamedGetter']
|
||||
if namedGetter:
|
||||
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() +
|
||||
"}\n")
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue