mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Kill dead callback codegen code
This commit is contained in:
parent
f903da0a7b
commit
74dabbdc62
1 changed files with 4 additions and 61 deletions
|
@ -6529,8 +6529,7 @@ class CGNativeMember(ClassMethod):
|
||||||
|
|
||||||
|
|
||||||
class CGCallback(CGClass):
|
class CGCallback(CGClass):
|
||||||
def __init__(self, idlObject, descriptorProvider, baseName, methods,
|
def __init__(self, idlObject, descriptorProvider, baseName, methods):
|
||||||
getters=[], setters=[]):
|
|
||||||
self.baseName = baseName
|
self.baseName = baseName
|
||||||
self._deps = idlObject.getDeps()
|
self._deps = idlObject.getDeps()
|
||||||
name = idlObject.identifier.name
|
name = idlObject.identifier.name
|
||||||
|
@ -6549,7 +6548,7 @@ class CGCallback(CGClass):
|
||||||
CGClass.__init__(self, name,
|
CGClass.__init__(self, name,
|
||||||
bases=[ClassBase(baseName)],
|
bases=[ClassBase(baseName)],
|
||||||
constructors=self.getConstructors(),
|
constructors=self.getConstructors(),
|
||||||
methods=realMethods + getters + setters,
|
methods=realMethods,
|
||||||
decorators="#[derive(JSTraceable, PartialEq)]\n#[allow_unrooted_interior]")
|
decorators="#[derive(JSTraceable, PartialEq)]\n#[allow_unrooted_interior]")
|
||||||
|
|
||||||
def getConstructors(self):
|
def getConstructors(self):
|
||||||
|
@ -6672,16 +6671,13 @@ class CGCallbackInterface(CGCallback):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
iface = descriptor.interface
|
iface = descriptor.interface
|
||||||
attrs = [m for m in iface.members if m.isAttr() and not m.isStatic()]
|
attrs = [m for m in iface.members if m.isAttr() and not m.isStatic()]
|
||||||
getters = [CallbackGetter(a, descriptor) for a in attrs]
|
assert not attrs
|
||||||
setters = [CallbackSetter(a, descriptor) for a in attrs
|
|
||||||
if not a.readonly]
|
|
||||||
methods = [m for m in iface.members
|
methods = [m for m in iface.members
|
||||||
if m.isMethod() and not m.isStatic() and not m.isIdentifierLess()]
|
if m.isMethod() and not m.isStatic() and not m.isIdentifierLess()]
|
||||||
methods = [CallbackOperation(m, sig, descriptor) for m in methods
|
methods = [CallbackOperation(m, sig, descriptor) for m in methods
|
||||||
for sig in m.signatures()]
|
for sig in m.signatures()]
|
||||||
assert not iface.isJSImplemented() or not iface.ctor()
|
assert not iface.isJSImplemented() or not iface.ctor()
|
||||||
CGCallback.__init__(self, iface, descriptor, "CallbackInterface",
|
CGCallback.__init__(self, iface, descriptor, "CallbackInterface", methods)
|
||||||
methods, getters=getters, setters=setters)
|
|
||||||
|
|
||||||
|
|
||||||
class FakeMember():
|
class FakeMember():
|
||||||
|
@ -6998,59 +6994,6 @@ class CallbackOperation(CallbackOperationBase):
|
||||||
descriptor, descriptor.interface.isSingleOperationInterface())
|
descriptor, descriptor.interface.isSingleOperationInterface())
|
||||||
|
|
||||||
|
|
||||||
class CallbackGetter(CallbackMember):
|
|
||||||
def __init__(self, attr, descriptor):
|
|
||||||
self.ensureASCIIName(attr)
|
|
||||||
self.attrName = attr.identifier.name
|
|
||||||
CallbackMember.__init__(self,
|
|
||||||
(attr.type, []),
|
|
||||||
callbackGetterName(attr),
|
|
||||||
descriptor,
|
|
||||||
needThisHandling=False)
|
|
||||||
|
|
||||||
def getRvalDecl(self):
|
|
||||||
return "Dom::Rooted<Dom::Value> rval(cx, JS::UndefinedValue());\n"
|
|
||||||
|
|
||||||
def getCall(self):
|
|
||||||
replacements = {
|
|
||||||
"attrName": self.attrName
|
|
||||||
}
|
|
||||||
return string.Template(
|
|
||||||
'if (!JS_GetProperty(cx, mCallback, "${attrName}", &rval)) {\n'
|
|
||||||
' return Err(JSFailed);\n'
|
|
||||||
'}\n').substitute(replacements)
|
|
||||||
|
|
||||||
|
|
||||||
class CallbackSetter(CallbackMember):
|
|
||||||
def __init__(self, attr, descriptor):
|
|
||||||
self.ensureASCIIName(attr)
|
|
||||||
self.attrName = attr.identifier.name
|
|
||||||
CallbackMember.__init__(self,
|
|
||||||
(BuiltinTypes[IDLBuiltinType.Types.void],
|
|
||||||
[FakeArgument(attr.type, attr)]),
|
|
||||||
callbackSetterName(attr),
|
|
||||||
descriptor,
|
|
||||||
needThisHandling=False)
|
|
||||||
|
|
||||||
def getRvalDecl(self):
|
|
||||||
# We don't need an rval
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def getCall(self):
|
|
||||||
replacements = {
|
|
||||||
"attrName": self.attrName,
|
|
||||||
"argv": "argv.handleAt(0)",
|
|
||||||
}
|
|
||||||
return string.Template(
|
|
||||||
'MOZ_ASSERT(argv.length() == 1);\n'
|
|
||||||
'if (!JS_SetProperty(cx, mCallback, "${attrName}", ${argv})) {\n'
|
|
||||||
' return Err(JSFailed);\n'
|
|
||||||
'}\n').substitute(replacements)
|
|
||||||
|
|
||||||
def getArgcDecl(self):
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class CGIterableMethodGenerator(CGGeneric):
|
class CGIterableMethodGenerator(CGGeneric):
|
||||||
"""
|
"""
|
||||||
Creates methods for iterable interfaces. Unwrapping/wrapping
|
Creates methods for iterable interfaces. Unwrapping/wrapping
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue