mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Auto merge of #7455 - nox:rm-unused-warnings, r=jdm
Do not allow some warnings in codegen anymore This fixes #395. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7455) <!-- Reviewable:end -->
This commit is contained in:
commit
a855669d4f
2 changed files with 31 additions and 29 deletions
|
@ -890,16 +890,21 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
else:
|
else:
|
||||||
handleInvalidEnumValueCode = "return JSTrue;"
|
handleInvalidEnumValueCode = "return JSTrue;"
|
||||||
|
|
||||||
|
transmute = "mem::transmute(index)"
|
||||||
|
if isMember == 'Dictionary':
|
||||||
|
transmute = 'unsafe { ' + transmute + ' }'
|
||||||
|
|
||||||
template = (
|
template = (
|
||||||
"match find_enum_string_index(cx, ${val}, %(values)s) {\n"
|
"match find_enum_string_index(cx, ${val}, %(values)s) {\n"
|
||||||
" Err(_) => { %(exceptionCode)s },\n"
|
" Err(_) => { %(exceptionCode)s },\n"
|
||||||
" Ok(None) => { %(handleInvalidEnumValueCode)s },\n"
|
" Ok(None) => { %(handleInvalidEnumValueCode)s },\n"
|
||||||
" Ok(Some(index)) => {\n"
|
" Ok(Some(index)) => {\n"
|
||||||
" //XXXjdm need some range checks up in here.\n"
|
" //XXXjdm need some range checks up in here.\n"
|
||||||
" unsafe { mem::transmute(index) }\n"
|
" %(transmute)s\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
"}" % {"values": enum + "Values::strings",
|
"}" % {"values": enum + "Values::strings",
|
||||||
"exceptionCode": exceptionCode,
|
"exceptionCode": exceptionCode,
|
||||||
|
"transmute": transmute,
|
||||||
"handleInvalidEnumValueCode": handleInvalidEnumValueCode})
|
"handleInvalidEnumValueCode": handleInvalidEnumValueCode})
|
||||||
|
|
||||||
if defaultValue is not None:
|
if defaultValue is not None:
|
||||||
|
@ -1621,19 +1626,11 @@ class CGImports(CGWrapper):
|
||||||
"""
|
"""
|
||||||
if ignored_warnings is None:
|
if ignored_warnings is None:
|
||||||
ignored_warnings = [
|
ignored_warnings = [
|
||||||
# Allow unreachable_code because we use 'break' in a way that
|
|
||||||
# sometimes produces two 'break's in a row. See for example
|
|
||||||
# CallbackMember.getArgConversions.
|
|
||||||
'unreachable_code',
|
|
||||||
'non_camel_case_types',
|
'non_camel_case_types',
|
||||||
'non_upper_case_globals',
|
'non_upper_case_globals',
|
||||||
'unused_parens',
|
|
||||||
'unused_imports',
|
'unused_imports',
|
||||||
'unused_variables',
|
'unused_variables',
|
||||||
'unused_unsafe',
|
|
||||||
'unused_mut',
|
|
||||||
'unused_assignments',
|
'unused_assignments',
|
||||||
'dead_code',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def componentTypes(type):
|
def componentTypes(type):
|
||||||
|
@ -2050,7 +2047,7 @@ class CGAbstractMethod(CGThing):
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor, name, returnType, args, inline=False,
|
def __init__(self, descriptor, name, returnType, args, inline=False,
|
||||||
alwaysInline=False, extern=False, pub=False, templateArgs=None,
|
alwaysInline=False, extern=False, pub=False, templateArgs=None,
|
||||||
unsafe=True):
|
unsafe=False):
|
||||||
CGThing.__init__(self)
|
CGThing.__init__(self)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -2112,7 +2109,7 @@ class CGAbstractMethod(CGThing):
|
||||||
|
|
||||||
|
|
||||||
def CreateBindingJSObject(descriptor, parent=None):
|
def CreateBindingJSObject(descriptor, parent=None):
|
||||||
create = "let mut raw = Box::into_raw(object);\nlet _rt = RootedTraceable::new(&*raw);\n"
|
create = "let raw = Box::into_raw(object);\nlet _rt = RootedTraceable::new(&*raw);\n"
|
||||||
if descriptor.proxy:
|
if descriptor.proxy:
|
||||||
assert not descriptor.isGlobal()
|
assert not descriptor.isGlobal()
|
||||||
create += """
|
create += """
|
||||||
|
@ -2161,12 +2158,13 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
assert not descriptor.interface.isCallback()
|
assert not descriptor.interface.isCallback()
|
||||||
if not descriptor.isGlobal():
|
if not descriptor.isGlobal():
|
||||||
args = [Argument('*mut JSContext', 'cx'), Argument('GlobalRef', 'scope'),
|
args = [Argument('*mut JSContext', 'cx'), Argument('GlobalRef', 'scope'),
|
||||||
Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)]
|
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||||
else:
|
else:
|
||||||
args = [Argument('*mut JSContext', 'cx'),
|
args = [Argument('*mut JSContext', 'cx'),
|
||||||
Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)]
|
Argument("Box<%s>" % descriptor.concreteType, 'object')]
|
||||||
retval = 'Root<%s>' % descriptor.concreteType
|
retval = 'Root<%s>' % descriptor.concreteType
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True)
|
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args,
|
||||||
|
pub=True, unsafe=True)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
if not self.descriptor.isGlobal():
|
if not self.descriptor.isGlobal():
|
||||||
|
@ -2310,6 +2308,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
protoChain = self.descriptor.prototypeChain
|
protoChain = self.descriptor.prototypeChain
|
||||||
if len(protoChain) == 1:
|
if len(protoChain) == 1:
|
||||||
|
self.unsafe = True
|
||||||
getParentProto = "parent_proto.ptr = JS_GetObjectPrototype(cx, global)"
|
getParentProto = "parent_proto.ptr = JS_GetObjectPrototype(cx, global)"
|
||||||
else:
|
else:
|
||||||
parentProtoName = self.descriptor.prototypeChain[-2]
|
parentProtoName = self.descriptor.prototypeChain[-2]
|
||||||
|
@ -2383,7 +2382,7 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
|
||||||
Argument('HandleObject', 'receiver'),
|
Argument('HandleObject', 'receiver'),
|
||||||
Argument('MutableHandleObject', 'rval')]
|
Argument('MutableHandleObject', 'rval')]
|
||||||
CGAbstractMethod.__init__(self, descriptor, name,
|
CGAbstractMethod.__init__(self, descriptor, name,
|
||||||
'void', args, pub=pub)
|
'void', args, pub=pub, unsafe=True)
|
||||||
self.id = idPrefix + "ID::" + self.descriptor.name
|
self.id = idPrefix + "ID::" + self.descriptor.name
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
|
@ -2453,7 +2452,9 @@ class CGDefineProxyHandler(CGAbstractMethod):
|
||||||
"""
|
"""
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
assert descriptor.proxy
|
assert descriptor.proxy
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'DefineProxyHandler', '*const libc::c_void', [], pub=True)
|
CGAbstractMethod.__init__(self, descriptor, 'DefineProxyHandler',
|
||||||
|
'*const libc::c_void', [],
|
||||||
|
pub=True, unsafe=True)
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
return CGAbstractMethod.define(self)
|
return CGAbstractMethod.define(self)
|
||||||
|
@ -2854,7 +2855,7 @@ class CGStaticMethod(CGAbstractStaticBindingMethod):
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
||||||
self.method)
|
self.method)
|
||||||
setupArgs = CGGeneric("let mut args = CallArgs::from_vp(vp, argc);\n")
|
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
||||||
call = CGMethodCall(["global.r()"], nativeName, True, self.descriptor, self.method)
|
call = CGMethodCall(["global.r()"], nativeName, True, self.descriptor, self.method)
|
||||||
return CGList([setupArgs, call])
|
return CGList([setupArgs, call])
|
||||||
|
|
||||||
|
@ -2908,7 +2909,7 @@ class CGStaticGetter(CGAbstractStaticBindingMethod):
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
setupArgs = CGGeneric("let mut args = CallArgs::from_vp(vp, argc);\n")
|
setupArgs = CGGeneric("let args = CallArgs::from_vp(vp, argc);\n")
|
||||||
call = CGGetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
call = CGGetterCall(["global.r()"], self.attr.type, nativeName, self.descriptor,
|
||||||
self.attr)
|
self.attr)
|
||||||
return CGList([setupArgs, call])
|
return CGList([setupArgs, call])
|
||||||
|
@ -2958,7 +2959,7 @@ class CGStaticSetter(CGAbstractStaticBindingMethod):
|
||||||
self.attr)
|
self.attr)
|
||||||
checkForArg = CGGeneric(
|
checkForArg = CGGeneric(
|
||||||
"let args = CallArgs::from_vp(vp, argc);\n"
|
"let args = CallArgs::from_vp(vp, argc);\n"
|
||||||
"if (argc == 0) {\n"
|
"if argc == 0 {\n"
|
||||||
" throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
|
" throw_type_error(cx, \"Not enough arguments to %s setter.\");\n"
|
||||||
" return JSFalse;\n"
|
" return JSFalse;\n"
|
||||||
"}" % self.attr.identifier.name)
|
"}" % self.attr.identifier.name)
|
||||||
|
@ -4032,7 +4033,8 @@ class CGProxyUnwrap(CGAbstractMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
args = [Argument('HandleObject', 'obj')]
|
args = [Argument('HandleObject', 'obj')]
|
||||||
CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy",
|
CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy",
|
||||||
'*const ' + descriptor.concreteType, args, alwaysInline=True)
|
'*const ' + descriptor.concreteType, args,
|
||||||
|
alwaysInline=True, unsafe=True)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric("""\
|
return CGGeneric("""\
|
||||||
|
@ -4229,7 +4231,7 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
|
||||||
for name in (*unwrapped_proxy).SupportedPropertyNames() {
|
for name in (*unwrapped_proxy).SupportedPropertyNames() {
|
||||||
let cstring = CString::new(name).unwrap();
|
let cstring = CString::new(name).unwrap();
|
||||||
let jsstring = JS_InternString(cx, cstring.as_ptr());
|
let jsstring = JS_InternString(cx, cstring.as_ptr());
|
||||||
let mut rooted = RootedString::new(cx, jsstring);
|
let rooted = RootedString::new(cx, jsstring);
|
||||||
let jsid = INTERNED_STRING_TO_JSID(cx, rooted.handle().get());
|
let jsid = INTERNED_STRING_TO_JSID(cx, rooted.handle().get());
|
||||||
let rooted_jsid = RootedId::new(cx, jsid);
|
let rooted_jsid = RootedId::new(cx, jsid);
|
||||||
AppendToAutoIdVector(props, rooted_jsid.handle().get());
|
AppendToAutoIdVector(props, rooted_jsid.handle().get());
|
||||||
|
@ -4349,7 +4351,7 @@ if !expando.ptr.is_null() {
|
||||||
|
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
getNamed = ("if (RUST_JSID_IS_STRING(id) != 0) {\n" +
|
getNamed = ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
CGIndenter(CGProxyNamedGetter(self.descriptor, templateValues)).define() +
|
||||||
"}\n")
|
"}\n")
|
||||||
else:
|
else:
|
||||||
|
@ -5517,7 +5519,7 @@ class CallbackMember(CGNativeMember):
|
||||||
conversion = (
|
conversion = (
|
||||||
CGIfWrapper(CGGeneric(conversion),
|
CGIfWrapper(CGGeneric(conversion),
|
||||||
"%s.is_some()" % arg.identifier.name).define() +
|
"%s.is_some()" % arg.identifier.name).define() +
|
||||||
" else if (argc == %d) {\n"
|
" else if argc == %d {\n"
|
||||||
" // This is our current trailing argument; reduce argc\n"
|
" // This is our current trailing argument; reduce argc\n"
|
||||||
" argc -= 1;\n"
|
" argc -= 1;\n"
|
||||||
"} else {\n"
|
"} else {\n"
|
||||||
|
@ -5550,6 +5552,8 @@ class CallbackMember(CGNativeMember):
|
||||||
"}\n")
|
"}\n")
|
||||||
|
|
||||||
def getArgcDecl(self):
|
def getArgcDecl(self):
|
||||||
|
if self.argCount <= 1:
|
||||||
|
return CGGeneric("let argc = %s;" % self.argCountStr)
|
||||||
return CGGeneric("let mut argc = %s;" % self.argCountStr)
|
return CGGeneric("let mut argc = %s;" % self.argCountStr)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -168,15 +168,13 @@ pub mod codegen {
|
||||||
pub mod PrototypeList {
|
pub mod PrototypeList {
|
||||||
include!(concat!(env!("OUT_DIR"), "/PrototypeList.rs"));
|
include!(concat!(env!("OUT_DIR"), "/PrototypeList.rs"));
|
||||||
}
|
}
|
||||||
#[allow(unreachable_code, non_camel_case_types, non_upper_case_globals, unused_parens,
|
#[allow(non_camel_case_types, non_upper_case_globals,
|
||||||
unused_imports, unused_variables, unused_unsafe, unused_mut, unused_assignments,
|
unused_imports, unused_variables, unused_assignments)]
|
||||||
dead_code)]
|
|
||||||
pub mod RegisterBindings {
|
pub mod RegisterBindings {
|
||||||
include!(concat!(env!("OUT_DIR"), "/RegisterBindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/RegisterBindings.rs"));
|
||||||
}
|
}
|
||||||
#[allow(unreachable_code, non_camel_case_types, non_upper_case_globals, unused_parens,
|
#[allow(non_camel_case_types, non_upper_case_globals,
|
||||||
unused_imports, unused_variables, unused_unsafe, unused_mut, unused_assignments,
|
unused_imports, unused_variables, unused_assignments)]
|
||||||
dead_code)]
|
|
||||||
pub mod UnionTypes {
|
pub mod UnionTypes {
|
||||||
include!(concat!(env!("OUT_DIR"), "/UnionTypes.rs"));
|
include!(concat!(env!("OUT_DIR"), "/UnionTypes.rs"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue