зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #2807 - Remove some dead code and fix some pyflakes warnings in CodegenRust.py (from Ms2ger:pyflakes-2)
Source-Repo: https://github.com/servo/servo Source-Revision: f47b66b0c1a90176aa037082b38559ecbe1f67de
This commit is contained in:
Родитель
4b3a4f0ded
Коммит
823037bd6a
|
@ -4,13 +4,20 @@
|
||||||
|
|
||||||
# Common codegen classes.
|
# Common codegen classes.
|
||||||
|
|
||||||
import os
|
|
||||||
import string
|
|
||||||
import operator
|
import operator
|
||||||
import itertools
|
import os
|
||||||
|
import re
|
||||||
|
import string
|
||||||
|
|
||||||
from WebIDL import *
|
from WebIDL import (
|
||||||
from Configuration import getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, Descriptor
|
BuiltinTypes,
|
||||||
|
IDLBuiltinType,
|
||||||
|
IDLNullValue,
|
||||||
|
IDLType,
|
||||||
|
IDLUndefinedValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
from Configuration import getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback
|
||||||
|
|
||||||
AUTOGENERATED_WARNING_COMMENT = \
|
AUTOGENERATED_WARNING_COMMENT = \
|
||||||
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
|
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
|
||||||
|
@ -2103,12 +2110,6 @@ def needCx(returnType, arguments, extendedAttributes, considerTypes):
|
||||||
(typeNeedsCx(returnType, True) or
|
(typeNeedsCx(returnType, True) or
|
||||||
any(typeNeedsCx(a.type) for a in arguments)))
|
any(typeNeedsCx(a.type) for a in arguments)))
|
||||||
|
|
||||||
def needScopeObject(returnType, arguments, extendedAttributes,
|
|
||||||
isWrapperCached, considerTypes):
|
|
||||||
return (considerTypes and not isWrapperCached and
|
|
||||||
(typeNeedsScopeObject(returnType, True) or
|
|
||||||
any(typeNeedsScopeObject(a.type) for a in arguments)))
|
|
||||||
|
|
||||||
class CGCallGenerator(CGThing):
|
class CGCallGenerator(CGThing):
|
||||||
"""
|
"""
|
||||||
A class to generate an actual call to a C++ object. Assumes that the C++
|
A class to generate an actual call to a C++ object. Assumes that the C++
|
||||||
|
@ -4579,10 +4580,6 @@ class CGNativeMember(ClassMethod):
|
||||||
if needCx(returnType, argList, self.extendedAttrs,
|
if needCx(returnType, argList, self.extendedAttrs,
|
||||||
self.passJSBitsAsNeeded):
|
self.passJSBitsAsNeeded):
|
||||||
args.insert(0, Argument("JSContext*", "cx"))
|
args.insert(0, Argument("JSContext*", "cx"))
|
||||||
if needScopeObject(returnType, argList, self.extendedAttrs,
|
|
||||||
self.descriptorProvider,
|
|
||||||
self.passJSBitsAsNeeded):
|
|
||||||
args.insert(1, Argument("JS::Handle<JSObject*>", "obj"))
|
|
||||||
# And if we're static, a global
|
# And if we're static, a global
|
||||||
if self.member.isStatic():
|
if self.member.isStatic():
|
||||||
args.insert(0, Argument("const GlobalObject&", "global"))
|
args.insert(0, Argument("const GlobalObject&", "global"))
|
||||||
|
@ -4731,18 +4728,12 @@ class CGNativeMember(ClassMethod):
|
||||||
|
|
||||||
return Argument(decl.define(), arg.identifier.name)
|
return Argument(decl.define(), arg.identifier.name)
|
||||||
|
|
||||||
def isJSImplementedDescriptor(descriptorProvider):
|
|
||||||
return (isinstance(descriptorProvider, Descriptor) and
|
|
||||||
descriptorProvider.interface.isJSImplemented())
|
|
||||||
|
|
||||||
class CGCallback(CGClass):
|
class CGCallback(CGClass):
|
||||||
def __init__(self, idlObject, descriptorProvider, baseName, methods,
|
def __init__(self, idlObject, descriptorProvider, baseName, methods,
|
||||||
getters=[], setters=[]):
|
getters=[], setters=[]):
|
||||||
self.baseName = baseName
|
self.baseName = baseName
|
||||||
self._deps = idlObject.getDeps()
|
self._deps = idlObject.getDeps()
|
||||||
name = idlObject.identifier.name
|
name = idlObject.identifier.name
|
||||||
if isJSImplementedDescriptor(descriptorProvider):
|
|
||||||
name = jsImplName(name)
|
|
||||||
# For our public methods that needThisHandling we want most of the
|
# For our public methods that needThisHandling we want most of the
|
||||||
# same args and the same return type as what CallbackMember
|
# same args and the same return type as what CallbackMember
|
||||||
# generates. So we want to take advantage of all its
|
# generates. So we want to take advantage of all its
|
||||||
|
@ -4884,11 +4875,7 @@ class CGCallbackInterface(CGCallback):
|
||||||
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()]
|
||||||
if iface.isJSImplemented() and iface.ctor():
|
assert not iface.isJSImplemented() or not iface.ctor()
|
||||||
sigs = descriptor.interface.ctor().signatures()
|
|
||||||
if len(sigs) != 1:
|
|
||||||
raise TypeError("We only handle one constructor. See bug 869268.")
|
|
||||||
methods.append(CGJSImplInitOperation(sigs[0], descriptor))
|
|
||||||
CGCallback.__init__(self, iface, descriptor, "CallbackInterface",
|
CGCallback.__init__(self, iface, descriptor, "CallbackInterface",
|
||||||
methods, getters=getters, setters=setters)
|
methods, getters=getters, setters=setters)
|
||||||
|
|
||||||
|
@ -4983,15 +4970,11 @@ class CallbackMember(CGNativeMember):
|
||||||
"declName": "rvalDecl",
|
"declName": "rvalDecl",
|
||||||
}
|
}
|
||||||
|
|
||||||
if isJSImplementedDescriptor(self.descriptorProvider):
|
|
||||||
isCallbackReturnValue = "JSImpl"
|
|
||||||
else:
|
|
||||||
isCallbackReturnValue = "Callback"
|
|
||||||
template, _, declType, needsRooting = getJSToNativeConversionTemplate(
|
template, _, declType, needsRooting = getJSToNativeConversionTemplate(
|
||||||
self.retvalType,
|
self.retvalType,
|
||||||
self.descriptorProvider,
|
self.descriptorProvider,
|
||||||
exceptionCode=self.exceptionCode,
|
exceptionCode=self.exceptionCode,
|
||||||
isCallbackReturnValue=isCallbackReturnValue,
|
isCallbackReturnValue="Callback",
|
||||||
# XXXbz we should try to do better here
|
# XXXbz we should try to do better here
|
||||||
sourceDescription="return value")
|
sourceDescription="return value")
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче