mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
clippy: Fix warnings in generated code (#31721)
* clippy: remove extra static lifetimes in generated code * clippy: fix return and cast in generated code * clippy: fix more warnings in codegen * clippy: fix all errors from generated files
This commit is contained in:
parent
1a46529560
commit
99ddab43e8
1 changed files with 49 additions and 41 deletions
|
@ -420,14 +420,14 @@ class CGMethodCall(CGThing):
|
||||||
caseBody.append(CGGeneric("if %s.get().is_object() {" %
|
caseBody.append(CGGeneric("if %s.get().is_object() {" %
|
||||||
(distinguishingArg)))
|
(distinguishingArg)))
|
||||||
for idx, sig in enumerate(interfacesSigs):
|
for idx, sig in enumerate(interfacesSigs):
|
||||||
caseBody.append(CGIndenter(CGGeneric("loop {")))
|
caseBody.append(CGIndenter(CGGeneric("'_block: {")))
|
||||||
type = sig[1][distinguishingIndex].type
|
type = sig[1][distinguishingIndex].type
|
||||||
|
|
||||||
# The argument at index distinguishingIndex can't possibly
|
# The argument at index distinguishingIndex can't possibly
|
||||||
# be unset here, because we've already checked that argc is
|
# be unset here, because we've already checked that argc is
|
||||||
# large enough that we can examine this argument.
|
# large enough that we can examine this argument.
|
||||||
info = getJSToNativeConversionInfo(
|
info = getJSToNativeConversionInfo(
|
||||||
type, descriptor, failureCode="break;", isDefinitelyObject=True)
|
type, descriptor, failureCode="break '_block;", isDefinitelyObject=True)
|
||||||
template = info.template
|
template = info.template
|
||||||
declType = info.declType
|
declType = info.declType
|
||||||
|
|
||||||
|
@ -1410,7 +1410,7 @@ if %(argc)s > %(index)s {
|
||||||
return self.converter.define()
|
return self.converter.define()
|
||||||
|
|
||||||
|
|
||||||
def wrapForType(jsvalRef, result='result', successCode='return true;', pre=''):
|
def wrapForType(jsvalRef, result='result', successCode='true', pre=''):
|
||||||
"""
|
"""
|
||||||
Reflect a Rust value into JS.
|
Reflect a Rust value into JS.
|
||||||
|
|
||||||
|
@ -1672,11 +1672,11 @@ class PropertyDefiner:
|
||||||
prefableSpecs.append(
|
prefableSpecs.append(
|
||||||
prefableTemplate % (cond, name + "_specs", len(specs) - 1))
|
prefableTemplate % (cond, name + "_specs", len(specs) - 1))
|
||||||
|
|
||||||
specsArray = ("const %s_specs: &'static [&'static[%s]] = &[\n"
|
specsArray = ("const %s_specs: &[&[%s]] = &[\n"
|
||||||
+ ",\n".join(specs) + "\n"
|
+ ",\n".join(specs) + "\n"
|
||||||
+ "];\n") % (name, specType)
|
+ "];\n") % (name, specType)
|
||||||
|
|
||||||
prefArray = ("const %s: &'static [Guard<&'static [%s]>] = &[\n"
|
prefArray = ("const %s: &[Guard<&[%s]>] = &[\n"
|
||||||
+ ",\n".join(prefableSpecs) + "\n"
|
+ ",\n".join(prefableSpecs) + "\n"
|
||||||
+ "];\n") % (name, specType)
|
+ "];\n") % (name, specType)
|
||||||
return specsArray + prefArray
|
return specsArray + prefArray
|
||||||
|
@ -1851,6 +1851,8 @@ class MethodDefiner(PropertyDefiner):
|
||||||
flags = m["flags"]
|
flags = m["flags"]
|
||||||
if self.unforgeable:
|
if self.unforgeable:
|
||||||
flags += " | JSPROP_PERMANENT | JSPROP_READONLY"
|
flags += " | JSPROP_PERMANENT | JSPROP_READONLY"
|
||||||
|
if flags != "0":
|
||||||
|
flags = f"({flags}) as u16"
|
||||||
if "selfHostedName" in m:
|
if "selfHostedName" in m:
|
||||||
selfHostedName = '%s as *const u8 as *const libc::c_char' % str_to_const_array(m["selfHostedName"])
|
selfHostedName = '%s as *const u8 as *const libc::c_char' % str_to_const_array(m["selfHostedName"])
|
||||||
assert not m.get("methodInfo", True)
|
assert not m.get("methodInfo", True)
|
||||||
|
@ -1882,7 +1884,7 @@ class MethodDefiner(PropertyDefiner):
|
||||||
' name: %s,\n'
|
' name: %s,\n'
|
||||||
' call: JSNativeWrapper { op: %s, info: %s },\n'
|
' call: JSNativeWrapper { op: %s, info: %s },\n'
|
||||||
' nargs: %s,\n'
|
' nargs: %s,\n'
|
||||||
' flags: (%s) as u16,\n'
|
' flags: %s,\n'
|
||||||
' selfHostedName: %s\n'
|
' selfHostedName: %s\n'
|
||||||
' }')
|
' }')
|
||||||
specTerminator = (
|
specTerminator = (
|
||||||
|
@ -2015,7 +2017,7 @@ class AttrDefiner(PropertyDefiner):
|
||||||
if m["name"] == "@@toStringTag":
|
if m["name"] == "@@toStringTag":
|
||||||
return """ JSPropertySpec {
|
return """ JSPropertySpec {
|
||||||
name: JSPropertySpec_Name { symbol_: SymbolCode::%s as usize + 1 },
|
name: JSPropertySpec_Name { symbol_: SymbolCode::%s as usize + 1 },
|
||||||
attributes_: (%s) as u8,
|
attributes_: (%s),
|
||||||
kind_: (%s),
|
kind_: (%s),
|
||||||
u: JSPropertySpec_AccessorsOrValue {
|
u: JSPropertySpec_AccessorsOrValue {
|
||||||
value: JSPropertySpec_ValueWrapper {
|
value: JSPropertySpec_ValueWrapper {
|
||||||
|
@ -2029,7 +2031,7 @@ class AttrDefiner(PropertyDefiner):
|
||||||
"""
|
"""
|
||||||
return """ JSPropertySpec {
|
return """ JSPropertySpec {
|
||||||
name: JSPropertySpec_Name { string_: %s as *const u8 as *const libc::c_char },
|
name: JSPropertySpec_Name { string_: %s as *const u8 as *const libc::c_char },
|
||||||
attributes_: (%s) as u8,
|
attributes_: (%s),
|
||||||
kind_: (%s),
|
kind_: (%s),
|
||||||
u: JSPropertySpec_AccessorsOrValue {
|
u: JSPropertySpec_AccessorsOrValue {
|
||||||
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
|
accessors: JSPropertySpec_AccessorsOrValue_Accessors {
|
||||||
|
@ -2171,6 +2173,11 @@ class CGImports(CGWrapper):
|
||||||
'unused_variables',
|
'unused_variables',
|
||||||
'unused_assignments',
|
'unused_assignments',
|
||||||
'unused_mut',
|
'unused_mut',
|
||||||
|
'clippy::approx_constant',
|
||||||
|
'clippy::let_unit_value',
|
||||||
|
'clippy::needless_return',
|
||||||
|
'clippy::too_many_arguments',
|
||||||
|
'clippy::unnecessary_cast',
|
||||||
]
|
]
|
||||||
|
|
||||||
def componentTypes(type):
|
def componentTypes(type):
|
||||||
|
@ -2483,13 +2490,13 @@ static PrototypeClass: JSClass = JSClass {
|
||||||
name: %(name)s as *const u8 as *const libc::c_char,
|
name: %(name)s as *const u8 as *const libc::c_char,
|
||||||
flags:
|
flags:
|
||||||
// JSCLASS_HAS_RESERVED_SLOTS(%(slotCount)s)
|
// JSCLASS_HAS_RESERVED_SLOTS(%(slotCount)s)
|
||||||
(%(slotCount)s & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT,
|
(%(slotCount)s ) << JSCLASS_RESERVED_SLOTS_SHIFT,
|
||||||
cOps: 0 as *const _,
|
cOps: 0 as *const _,
|
||||||
spec: ptr::null(),
|
spec: ptr::null(),
|
||||||
ext: ptr::null(),
|
ext: ptr::null(),
|
||||||
oOps: ptr::null(),
|
oOps: ptr::null(),
|
||||||
};
|
};
|
||||||
""" % {'name': name, 'slotCount': slotCount}
|
""" % {'name': name, 'slotCount': f"{slotCount} & JSCLASS_RESERVED_SLOTS_MASK" if slotCount > 0 else "0"}
|
||||||
|
|
||||||
|
|
||||||
class CGInterfaceObjectJSClass(CGThing):
|
class CGInterfaceObjectJSClass(CGThing):
|
||||||
|
@ -2800,7 +2807,7 @@ class CGAbstractMethod(CGThing):
|
||||||
)
|
)
|
||||||
post = (
|
post = (
|
||||||
"\n})());\n"
|
"\n})());\n"
|
||||||
"return result"
|
"result"
|
||||||
)
|
)
|
||||||
body = CGWrapper(CGIndenter(body), pre=pre, post=post)
|
body = CGWrapper(CGIndenter(body), pre=pre, post=post)
|
||||||
|
|
||||||
|
@ -2956,7 +2963,7 @@ assert!(!obj.is_null());
|
||||||
SetProxyReservedSlot(
|
SetProxyReservedSlot(
|
||||||
obj.get(),
|
obj.get(),
|
||||||
0,
|
0,
|
||||||
&PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
|
&PrivateValue(raw.as_ptr() as *const libc::c_void),
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
create = create % {"concreteType": self.descriptor.concreteType,
|
create = create % {"concreteType": self.descriptor.concreteType,
|
||||||
|
@ -2983,7 +2990,7 @@ assert!(!obj.is_null());
|
||||||
JS_SetReservedSlot(
|
JS_SetReservedSlot(
|
||||||
obj.get(),
|
obj.get(),
|
||||||
DOM_OBJECT_SLOT,
|
DOM_OBJECT_SLOT,
|
||||||
&PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
|
&PrivateValue(raw.as_ptr() as *const libc::c_void),
|
||||||
);
|
);
|
||||||
"""
|
"""
|
||||||
create = create % {"concreteType": self.descriptor.concreteType}
|
create = create % {"concreteType": self.descriptor.concreteType}
|
||||||
|
@ -3051,7 +3058,7 @@ rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
|
||||||
create_global_object(
|
create_global_object(
|
||||||
cx,
|
cx,
|
||||||
&Class.base,
|
&Class.base,
|
||||||
raw.as_ptr() as *const %(concreteType)s as *const libc::c_void,
|
raw.as_ptr() as *const libc::c_void,
|
||||||
_trace,
|
_trace,
|
||||||
obj.handle_mut(),
|
obj.handle_mut(),
|
||||||
origin);
|
origin);
|
||||||
|
@ -3091,9 +3098,9 @@ class CGIDLInterface(CGThing):
|
||||||
depth = self.descriptor.prototypeDepth
|
depth = self.descriptor.prototypeDepth
|
||||||
check = "class.interface_chain[%s] == PrototypeList::ID::%s" % (depth, name)
|
check = "class.interface_chain[%s] == PrototypeList::ID::%s" % (depth, name)
|
||||||
elif self.descriptor.proxy:
|
elif self.descriptor.proxy:
|
||||||
check = "class as *const _ == &Class as *const _"
|
check = "ptr::eq(class, &Class)"
|
||||||
else:
|
else:
|
||||||
check = "class as *const _ == &Class.dom_class as *const _"
|
check = "ptr::eq(class, &Class.dom_class)"
|
||||||
return """\
|
return """\
|
||||||
impl IDLInterface for %(name)s {
|
impl IDLInterface for %(name)s {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -3104,7 +3111,7 @@ impl IDLInterface for %(name)s {
|
||||||
|
|
||||||
impl PartialEq for %(name)s {
|
impl PartialEq for %(name)s {
|
||||||
fn eq(&self, other: &%(name)s) -> bool {
|
fn eq(&self, other: &%(name)s) -> bool {
|
||||||
self as *const %(name)s == &*other
|
self as *const %(name)s == other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""" % {'check': check, 'name': name}
|
""" % {'check': check, 'name': name}
|
||||||
|
@ -3268,7 +3275,7 @@ let global = incumbent_global.reflector().get_jsobject();\n"""
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
name=name, nameAsArray=str_to_const_array(name), conditions=ret_conditions)
|
name=name, nameAsArray=str_to_const_array(name), conditions=ret_conditions)
|
||||||
ret += 'return true;\n'
|
ret += 'true\n'
|
||||||
return CGGeneric(ret)
|
return CGGeneric(ret)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3381,14 +3388,14 @@ assert!(!prototype_proto.is_null());""" % name))
|
||||||
code.append(CGGeneric("""
|
code.append(CGGeneric("""
|
||||||
rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
|
rooted!(in(*cx) let mut prototype = ptr::null_mut::<JSObject>());
|
||||||
create_interface_prototype_object(cx,
|
create_interface_prototype_object(cx,
|
||||||
global.into(),
|
global,
|
||||||
prototype_proto.handle().into(),
|
prototype_proto.handle(),
|
||||||
&PrototypeClass,
|
&PrototypeClass,
|
||||||
%(methods)s,
|
%(methods)s,
|
||||||
%(attrs)s,
|
%(attrs)s,
|
||||||
%(consts)s,
|
%(consts)s,
|
||||||
%(unscopables)s,
|
%(unscopables)s,
|
||||||
prototype.handle_mut().into());
|
prototype.handle_mut());
|
||||||
assert!(!prototype.is_null());
|
assert!(!prototype.is_null());
|
||||||
assert!((*cache)[PrototypeList::ID::%(id)s as usize].is_null());
|
assert!((*cache)[PrototypeList::ID::%(id)s as usize].is_null());
|
||||||
(*cache)[PrototypeList::ID::%(id)s as usize] = prototype.get();
|
(*cache)[PrototypeList::ID::%(id)s as usize] = prototype.get();
|
||||||
|
@ -3416,7 +3423,7 @@ assert!(!interface_proto.is_null());
|
||||||
|
|
||||||
rooted!(in(*cx) let mut interface = ptr::null_mut::<JSObject>());
|
rooted!(in(*cx) let mut interface = ptr::null_mut::<JSObject>());
|
||||||
create_noncallback_interface_object(cx,
|
create_noncallback_interface_object(cx,
|
||||||
global.into(),
|
global,
|
||||||
interface_proto.handle(),
|
interface_proto.handle(),
|
||||||
&INTERFACE_OBJECT_CLASS,
|
&INTERFACE_OBJECT_CLASS,
|
||||||
%(static_methods)s,
|
%(static_methods)s,
|
||||||
|
@ -3455,6 +3462,8 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
||||||
defineFn = "JS_DefineProperty"
|
defineFn = "JS_DefineProperty"
|
||||||
prop = '"%s"' % alias
|
prop = '"%s"' % alias
|
||||||
enumFlags = "JSPROP_ENUMERATE"
|
enumFlags = "JSPROP_ENUMERATE"
|
||||||
|
if enumFlags != "0":
|
||||||
|
enumFlags = f"{enumFlags} as u32"
|
||||||
return CGList([
|
return CGList([
|
||||||
getSymbolJSID,
|
getSymbolJSID,
|
||||||
# XXX If we ever create non-enumerable properties that can
|
# XXX If we ever create non-enumerable properties that can
|
||||||
|
@ -3462,8 +3471,7 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
||||||
# match the enumerability of the property being aliased.
|
# match the enumerability of the property being aliased.
|
||||||
CGGeneric(fill(
|
CGGeneric(fill(
|
||||||
"""
|
"""
|
||||||
assert!(${defineFn}(*cx, prototype.handle(), ${prop}, aliasedVal.handle(),
|
assert!(${defineFn}(*cx, prototype.handle(), ${prop}, aliasedVal.handle(), ${enumFlags}));
|
||||||
${enumFlags} as u32));
|
|
||||||
""",
|
""",
|
||||||
defineFn=defineFn,
|
defineFn=defineFn,
|
||||||
prop=prop,
|
prop=prop,
|
||||||
|
@ -3492,7 +3500,7 @@ assert!((*cache)[PrototypeList::Constructor::%(id)s as usize].is_null());
|
||||||
|
|
||||||
constructors = self.descriptor.interface.legacyFactoryFunctions
|
constructors = self.descriptor.interface.legacyFactoryFunctions
|
||||||
if constructors:
|
if constructors:
|
||||||
decl = "let named_constructors: [(ConstructorClassHook, &'static [u8], u32); %d]" % len(constructors)
|
decl = "let named_constructors: [(ConstructorClassHook, &[u8], u32); %d]" % len(constructors)
|
||||||
specs = []
|
specs = []
|
||||||
for constructor in constructors:
|
for constructor in constructors:
|
||||||
hook = CONSTRUCT_HOOK_NAME + "_" + constructor.identifier.name
|
hook = CONSTRUCT_HOOK_NAME + "_" + constructor.identifier.name
|
||||||
|
@ -3879,7 +3887,7 @@ class CGPerSignatureCall(CGThing):
|
||||||
return 'infallible' not in self.extendedAttributes
|
return 'infallible' not in self.extendedAttributes
|
||||||
|
|
||||||
def wrap_return_value(self):
|
def wrap_return_value(self):
|
||||||
return wrapForType('MutableHandleValue::from_raw(args.rval())')
|
return wrapForType('MutableHandleValue::from_raw(args.rval())', successCode='return true;')
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
return (self.cgRoot.define() + "\n" + self.wrap_return_value())
|
return (self.cgRoot.define() + "\n" + self.wrap_return_value())
|
||||||
|
@ -3972,7 +3980,7 @@ class CGSetterCall(CGPerSignatureCall):
|
||||||
|
|
||||||
def wrap_return_value(self):
|
def wrap_return_value(self):
|
||||||
# We have no return value
|
# We have no return value
|
||||||
return "\nreturn true;"
|
return "\ntrue"
|
||||||
|
|
||||||
def getArgc(self):
|
def getArgc(self):
|
||||||
return "1"
|
return "1"
|
||||||
|
@ -4090,7 +4098,7 @@ class CGDefaultToJSONMethod(CGSpecializedMethod):
|
||||||
parents -= 1
|
parents -= 1
|
||||||
ret += fill(form, parentclass="")
|
ret += fill(form, parentclass="")
|
||||||
ret += ('(*args).rval().set(ObjectValue(*result));\n'
|
ret += ('(*args).rval().set(ObjectValue(*result));\n'
|
||||||
'return true;\n')
|
'true\n')
|
||||||
return CGGeneric(ret)
|
return CGGeneric(ret)
|
||||||
|
|
||||||
|
|
||||||
|
@ -4666,7 +4674,7 @@ use js::rust::HandleValue;
|
||||||
use js::rust::MutableHandleValue;
|
use js::rust::MutableHandleValue;
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
|
|
||||||
pub const pairs: &'static [(&'static str, super::${ident})] = &[
|
pub const pairs: &[(&str, super::${ident})] = &[
|
||||||
${pairs},
|
${pairs},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -5645,7 +5653,7 @@ if !expando.is_null() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""" + namedGet + """\
|
""" + namedGet + """\
|
||||||
return true;"""
|
true"""
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
@ -5803,7 +5811,7 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
true
|
||||||
""")
|
""")
|
||||||
|
|
||||||
return body
|
return body
|
||||||
|
@ -5862,7 +5870,7 @@ class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
true
|
||||||
""")
|
""")
|
||||||
|
|
||||||
return body
|
return body
|
||||||
|
@ -5937,7 +5945,7 @@ if !expando.is_null() {
|
||||||
}
|
}
|
||||||
""" + named + """\
|
""" + named + """\
|
||||||
*bp = false;
|
*bp = false;
|
||||||
return true;"""
|
true"""
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
@ -6038,7 +6046,7 @@ if found {
|
||||||
}
|
}
|
||||||
%s
|
%s
|
||||||
vp.set(UndefinedValue());
|
vp.set(UndefinedValue());
|
||||||
return true;""" % (maybeCrossOriginGet, getIndexedOrExpando, getNamed)
|
true""" % (maybeCrossOriginGet, getIndexedOrExpando, getNamed)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
@ -6309,9 +6317,9 @@ class CGInterfaceTrait(CGThing):
|
||||||
methods = []
|
methods = []
|
||||||
for name, arguments, rettype in members():
|
for name, arguments, rettype in members():
|
||||||
arguments = list(arguments)
|
arguments = list(arguments)
|
||||||
methods.append(CGGeneric("%sfn %s(&self%s) -> %s;\n" % (
|
methods.append(CGGeneric("%sfn %s(&self%s)%s;\n" % (
|
||||||
'unsafe ' if contains_unsafe_arg(arguments) else '',
|
'unsafe ' if contains_unsafe_arg(arguments) else '',
|
||||||
name, fmt(arguments), rettype))
|
name, fmt(arguments), f" -> {rettype}" if rettype != '()' else ''))
|
||||||
)
|
)
|
||||||
|
|
||||||
if methods:
|
if methods:
|
||||||
|
@ -6772,7 +6780,7 @@ class CGDescriptor(CGThing):
|
||||||
if unscopableNames:
|
if unscopableNames:
|
||||||
haveUnscopables = True
|
haveUnscopables = True
|
||||||
cgThings.append(
|
cgThings.append(
|
||||||
CGList([CGGeneric("const unscopable_names: &'static [&'static [u8]] = &["),
|
CGList([CGGeneric("const unscopable_names: &[&[u8]] = &["),
|
||||||
CGIndenter(CGList([CGGeneric(str_to_const_array(name)) for
|
CGIndenter(CGList([CGGeneric(str_to_const_array(name)) for
|
||||||
name in unscopableNames], ",\n")),
|
name in unscopableNames], ",\n")),
|
||||||
CGGeneric("];\n")], "\n"))
|
CGGeneric("];\n")], "\n"))
|
||||||
|
@ -6791,7 +6799,7 @@ class CGDescriptor(CGThing):
|
||||||
haveLegacyWindowAliases = len(legacyWindowAliases) != 0
|
haveLegacyWindowAliases = len(legacyWindowAliases) != 0
|
||||||
if haveLegacyWindowAliases:
|
if haveLegacyWindowAliases:
|
||||||
cgThings.append(
|
cgThings.append(
|
||||||
CGList([CGGeneric("const legacy_window_aliases: &'static [&'static [u8]] = &["),
|
CGList([CGGeneric("const legacy_window_aliases: &[&[u8]] = &["),
|
||||||
CGIndenter(CGList([CGGeneric(str_to_const_array(name)) for
|
CGIndenter(CGList([CGGeneric(str_to_const_array(name)) for
|
||||||
name in legacyWindowAliases], ",\n")),
|
name in legacyWindowAliases], ",\n")),
|
||||||
CGGeneric("];\n")], "\n"))
|
CGGeneric("];\n")], "\n"))
|
||||||
|
@ -7618,9 +7626,9 @@ class CallbackMember(CGNativeMember):
|
||||||
# Check for variadic arguments
|
# Check for variadic arguments
|
||||||
lastArg = args[self.argCount - 1]
|
lastArg = args[self.argCount - 1]
|
||||||
if lastArg.variadic:
|
if lastArg.variadic:
|
||||||
|
argCount = "0" if self.argCount == 1 else f"({self.argCount} - 1)"
|
||||||
self.argCountStr = (
|
self.argCountStr = (
|
||||||
"(%d - 1) + %s.len()" % (self.argCount,
|
"%s + %s.len()" % (argCount, lastArg.identifier.name))
|
||||||
lastArg.identifier.name))
|
|
||||||
else:
|
else:
|
||||||
self.argCountStr = "%d" % self.argCount
|
self.argCountStr = "%d" % self.argCount
|
||||||
self.needThisHandling = needThisHandling
|
self.needThisHandling = needThisHandling
|
||||||
|
@ -8121,7 +8129,7 @@ class GlobalGenRoots():
|
||||||
CGWrapper(CGIndenter(CGList([CGGeneric('"' + name + '"') for name in protos],
|
CGWrapper(CGIndenter(CGList([CGGeneric('"' + name + '"') for name in protos],
|
||||||
",\n"),
|
",\n"),
|
||||||
indentLevel=4),
|
indentLevel=4),
|
||||||
pre="static INTERFACES: [&'static str; %d] = [\n" % len(protos),
|
pre="static INTERFACES: [&str; %d] = [\n" % len(protos),
|
||||||
post="\n];\n\n"),
|
post="\n];\n\n"),
|
||||||
CGGeneric("pub fn proto_id_to_name(proto_id: u16) -> &'static str {\n"
|
CGGeneric("pub fn proto_id_to_name(proto_id: u16) -> &'static str {\n"
|
||||||
" debug_assert!(proto_id < ID::Last as u16);\n"
|
" debug_assert!(proto_id < ID::Last as u16);\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue