mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Properly generate proxy stringifiers
This commit is contained in:
parent
adec683333
commit
2a2e8b176d
3 changed files with 3 additions and 22 deletions
|
@ -4089,25 +4089,6 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod):
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, "obj_toString", "*mut JSString", args)
|
CGAbstractExternMethod.__init__(self, descriptor, "obj_toString", "*mut JSString", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
stringifier = self.descriptor.operations['Stringifier']
|
|
||||||
if stringifier:
|
|
||||||
name = self.descriptor.binaryNameFor(stringifier.identifier.name)
|
|
||||||
nativeName = MakeNativeName(name)
|
|
||||||
signature = stringifier.signatures()[0]
|
|
||||||
returnType = signature[0]
|
|
||||||
extendedAttributes = self.descriptor.getExtendedAttributes(stringifier)
|
|
||||||
infallible = 'infallible' in extendedAttributes
|
|
||||||
if not infallible:
|
|
||||||
error = CGGeneric(
|
|
||||||
('ThrowMethodFailedWithDetails(cx, rv, "%s", "toString");\n' +
|
|
||||||
"return NULL;") % self.descriptor.interface.identifier.name)
|
|
||||||
else:
|
|
||||||
error = None
|
|
||||||
call = CGCallGenerator(error, [], "", returnType, extendedAttributes, self.descriptor, nativeName, False, object="UnwrapProxy(proxy)")
|
|
||||||
return call.define() + """\
|
|
||||||
JSString* jsresult;
|
|
||||||
return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;"""
|
|
||||||
|
|
||||||
return """proxyhandler::object_to_string(cx, "%s")""" % self.descriptor.name
|
return """proxyhandler::object_to_string(cx, "%s")""" % self.descriptor.name
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
|
@ -4247,7 +4228,7 @@ class CGInterfaceTrait(CGThing):
|
||||||
|
|
||||||
if descriptor.proxy:
|
if descriptor.proxy:
|
||||||
for name, operation in descriptor.operations.iteritems():
|
for name, operation in descriptor.operations.iteritems():
|
||||||
if not operation:
|
if not operation or operation.isStringifier():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
assert len(operation.signatures()) == 1
|
assert len(operation.signatures()) == 1
|
||||||
|
|
|
@ -254,7 +254,7 @@ class Descriptor(DescriptorProvider):
|
||||||
|
|
||||||
self._binaryNames = desc.get('binaryNames', {})
|
self._binaryNames = desc.get('binaryNames', {})
|
||||||
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
self._binaryNames.setdefault('__legacycaller', 'LegacyCall')
|
||||||
self._binaryNames.setdefault('__stringifier', 'Stringify')
|
self._binaryNames.setdefault('__stringifier', 'Stringifier')
|
||||||
|
|
||||||
for member in self.interface.members:
|
for member in self.interface.members:
|
||||||
if not member.isAttr() and not member.isMethod():
|
if not member.isAttr() and not member.isMethod():
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
// https://url.spec.whatwg.org/#URLUtils-stringification-behavior
|
||||||
fn Stringify(self) -> DOMString {
|
fn Stringifier(self) -> DOMString {
|
||||||
self.Href().0
|
self.Href().0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue