mirror of
https://github.com/servo/servo.git
synced 2025-06-12 18:34:39 +00:00
Remove some dead code from codegen as found by pyflakes.
This commit is contained in:
parent
4379809e88
commit
9d7478ab8a
2 changed files with 18 additions and 41 deletions
|
@ -9,7 +9,7 @@ import string
|
|||
import operator
|
||||
|
||||
from WebIDL import *
|
||||
from Configuration import NoSuchDescriptorError, Descriptor
|
||||
from Configuration import Descriptor
|
||||
|
||||
AUTOGENERATED_WARNING_COMMENT = \
|
||||
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
|
||||
|
@ -498,9 +498,6 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
# they really should be!
|
||||
if exceptionCode is None:
|
||||
exceptionCode = "return 0;"
|
||||
# We often want exceptionCode to be indented, since it often appears in an
|
||||
# if body.
|
||||
exceptionCodeIndented = CGIndenter(CGGeneric(exceptionCode))
|
||||
|
||||
# Unfortunately, .capitalize() on a string will lowercase things inside the
|
||||
# string, which we do not want.
|
||||
|
@ -620,12 +617,6 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
failureCode)
|
||||
return (template, declType, None, isOptional, None)
|
||||
|
||||
# Sequences and callbacks have to hold a strong ref to the thing being
|
||||
# passed down.
|
||||
forceOwningType = descriptor.interface.isCallback() or isMember
|
||||
|
||||
typePtr = descriptor.nativeType
|
||||
|
||||
templateBody = ""
|
||||
if descriptor.interface.isConsequential():
|
||||
raise TypeError("Consequential interface %s being used as an "
|
||||
|
@ -648,7 +639,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
templateBody = wrapObjectTemplate(templateBody, isDefinitelyObject,
|
||||
type, failureCode)
|
||||
|
||||
declType = CGGeneric(typePtr)
|
||||
declType = CGGeneric(descriptor.nativeType)
|
||||
if type.nullable() or isOptional:
|
||||
declType = CGWrapper(declType, pre="Option<", post=">")
|
||||
|
||||
|
@ -812,15 +803,9 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
assert not isOptional
|
||||
|
||||
typeName = CGDictionary.makeDictionaryName(type.inner)
|
||||
actualTypeName = typeName
|
||||
selfRef = "${declName}"
|
||||
|
||||
declType = CGGeneric(actualTypeName)
|
||||
|
||||
# If we're a member of something else, the const
|
||||
# will come from the Optional or our container.
|
||||
if not isMember:
|
||||
selfRef = "%s" % selfRef
|
||||
declType = CGGeneric(typeName)
|
||||
|
||||
# We do manual default value handling here, because we
|
||||
# actually do want a jsval, and we only handle null anyway
|
||||
|
@ -833,7 +818,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
template = ("%s = %s::new();\n"
|
||||
"if %s.Init(cx, %s) == 0 {\n"
|
||||
" return 0;\n"
|
||||
"}" % (selfRef, actualTypeName, selfRef, val))
|
||||
"}" % (selfRef, typeName, selfRef, val))
|
||||
|
||||
return (template, declType, None, False, None)
|
||||
|
||||
|
@ -846,11 +831,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
|
|||
if not type.isPrimitive():
|
||||
raise TypeError("Need conversion for argument type '%s'" % str(type))
|
||||
|
||||
conversionBehavior = "eDefault"
|
||||
if isEnforceRange:
|
||||
conversionBehavior = "eEnforceRange"
|
||||
elif isClamp:
|
||||
conversionBehavior = "eClamp"
|
||||
assert not isEnforceRange and not isClamp
|
||||
|
||||
if failureCode is None:
|
||||
failureCode = 'return 0'
|
||||
|
@ -934,8 +915,6 @@ def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
|
|||
|
||||
originalDeclName = replacements["declName"]
|
||||
if declType is not None:
|
||||
if dealWithOptional:
|
||||
mutableDeclType = CGWrapper(declType, pre="Option< ", post=" >")
|
||||
newDecl = [CGGeneric("let mut "),
|
||||
CGGeneric(originalDeclName),
|
||||
CGGeneric(": "),
|
||||
|
@ -2246,7 +2225,6 @@ class CGCallGenerator(CGThing):
|
|||
name = "(JSObject&)" + name
|
||||
#XXXjdm Perhaps we should pass all nontrivial types by borrowed pointer
|
||||
if a.type.isGeckoInterface():
|
||||
argDescriptor = descriptorProvider.getDescriptor(a.type.name)
|
||||
if not (a.type.nullable() or a.optional):
|
||||
name = "&mut " + name
|
||||
elif a.type.isDictionary():
|
||||
|
@ -2906,15 +2884,12 @@ def getUnionTypeTemplateVars(type, descriptorProvider):
|
|||
name = type.name
|
||||
typeName = "/*" + type.name + "*/"
|
||||
|
||||
(template, declType, holderType,
|
||||
(template, _, holderType,
|
||||
dealWithOptional, initialValue) = getJSToNativeConversionTemplate(
|
||||
type, descriptorProvider, failureCode="return Ok(None);",
|
||||
exceptionCode='return Err(());',
|
||||
isDefinitelyObject=True, isOptional=False)
|
||||
|
||||
structType = declType.define()
|
||||
externalType = getUnionAccessorSignatureType(type, descriptorProvider).define()
|
||||
|
||||
assert not type.isObject()
|
||||
jsConversion = string.Template(template).substitute({
|
||||
"val": "value",
|
||||
|
@ -3546,7 +3521,6 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
operation = descriptor.operations[operation]
|
||||
assert len(operation.signatures()) == 1
|
||||
signature = operation.signatures()[0]
|
||||
extendedAttributes = descriptor.getExtendedAttributes(operation)
|
||||
|
||||
(returnType, arguments) = signature
|
||||
|
||||
|
@ -4050,13 +4024,16 @@ class CGDescriptor(CGThing):
|
|||
else:
|
||||
hasSetter = True
|
||||
cgThings.append(CGMemberJITInfo(descriptor, m))
|
||||
if hasMethod: cgThings.append(CGGenericMethod(descriptor))
|
||||
if hasGetter: cgThings.append(CGGenericGetter(descriptor))
|
||||
#if hasLenientGetter: cgThings.append(CGGenericGetter(descriptor,
|
||||
# lenientThis=True))
|
||||
if hasSetter: cgThings.append(CGGenericSetter(descriptor))
|
||||
#if hasLenientSetter: cgThings.append(CGGenericSetter(descriptor,
|
||||
# lenientThis=True))
|
||||
if hasMethod:
|
||||
cgThings.append(CGGenericMethod(descriptor))
|
||||
if hasGetter:
|
||||
cgThings.append(CGGenericGetter(descriptor))
|
||||
if hasLenientGetter:
|
||||
pass
|
||||
if hasSetter:
|
||||
cgThings.append(CGGenericSetter(descriptor))
|
||||
if hasLenientSetter:
|
||||
pass
|
||||
|
||||
if descriptor.concrete:
|
||||
cgThings.append(CGClassFinalizeHook(descriptor))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue