mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Remove usage of various unsafe keyword
This commit is contained in:
parent
78034a90d0
commit
6c26518f61
3 changed files with 17 additions and 16 deletions
|
@ -50,7 +50,7 @@ fn main() {
|
||||||
let mut phf = File::create(&phf).unwrap();
|
let mut phf = File::create(&phf).unwrap();
|
||||||
write!(
|
write!(
|
||||||
&mut phf,
|
&mut phf,
|
||||||
"pub static MAP: phf::Map<&'static [u8], unsafe fn(JSContext, HandleObject)> = "
|
"pub static MAP: phf::Map<&'static [u8], fn(JSContext, HandleObject)> = "
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
map.build(&mut phf).unwrap();
|
map.build(&mut phf).unwrap();
|
||||||
|
|
|
@ -2588,8 +2588,7 @@ class CGConstructorEnabled(CGAbstractMethod):
|
||||||
CGAbstractMethod.__init__(self, descriptor,
|
CGAbstractMethod.__init__(self, descriptor,
|
||||||
'ConstructorEnabled', 'bool',
|
'ConstructorEnabled', 'bool',
|
||||||
[Argument("SafeJSContext", "aCx"),
|
[Argument("SafeJSContext", "aCx"),
|
||||||
Argument("HandleObject", "aObj")],
|
Argument("HandleObject", "aObj")])
|
||||||
unsafe=True)
|
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
conditions = []
|
conditions = []
|
||||||
|
@ -3137,23 +3136,25 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
|
||||||
Argument('HandleObject', 'global'),
|
Argument('HandleObject', 'global'),
|
||||||
Argument('MutableHandleObject', 'mut rval')]
|
Argument('MutableHandleObject', 'mut rval')]
|
||||||
CGAbstractMethod.__init__(self, descriptor, name,
|
CGAbstractMethod.__init__(self, descriptor, name,
|
||||||
'void', args, pub=pub, unsafe=True)
|
'void', args, pub=pub)
|
||||||
self.id = idPrefix + "::" + MakeNativeName(self.descriptor.name)
|
self.id = idPrefix + "::" + MakeNativeName(self.descriptor.name)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric("""
|
return CGGeneric("""
|
||||||
assert!(((*get_object_class(global.get())).flags & JSCLASS_DOM_GLOBAL) != 0);
|
unsafe {
|
||||||
|
assert!(((*get_object_class(global.get())).flags & JSCLASS_DOM_GLOBAL) != 0);
|
||||||
|
|
||||||
/* Check to see whether the interface objects are already installed */
|
/* Check to see whether the interface objects are already installed */
|
||||||
let proto_or_iface_array = get_proto_or_iface_array(global.get());
|
let proto_or_iface_array = get_proto_or_iface_array(global.get());
|
||||||
rval.set((*proto_or_iface_array)[%(id)s as usize]);
|
rval.set((*proto_or_iface_array)[%(id)s as usize]);
|
||||||
if !rval.get().is_null() {
|
if !rval.get().is_null() {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateInterfaceObjects(cx, global, proto_or_iface_array);
|
||||||
|
rval.set((*proto_or_iface_array)[%(id)s as usize]);
|
||||||
|
assert!(!rval.get().is_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateInterfaceObjects(cx, global, proto_or_iface_array);
|
|
||||||
rval.set((*proto_or_iface_array)[%(id)s as usize]);
|
|
||||||
assert!(!rval.get().is_null());
|
|
||||||
""" % {"id": self.id})
|
""" % {"id": self.id})
|
||||||
|
|
||||||
|
|
||||||
|
@ -3274,7 +3275,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
Argument('HandleObject', 'global'),
|
Argument('HandleObject', 'global'),
|
||||||
]
|
]
|
||||||
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface',
|
CGAbstractMethod.__init__(self, descriptor, 'DefineDOMInterface',
|
||||||
'void', args, pub=True, unsafe=True)
|
'void', args, pub=True)
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
return CGAbstractMethod.define(self)
|
return CGAbstractMethod.define(self)
|
||||||
|
|
|
@ -202,7 +202,7 @@ pub fn get_constructor_object_from_local_name(
|
||||||
) -> bool {
|
) -> bool {
|
||||||
macro_rules! get_constructor(
|
macro_rules! get_constructor(
|
||||||
($binding:ident) => ({
|
($binding:ident) => ({
|
||||||
unsafe { $binding::GetConstructorObject(cx, global, rval); }
|
$binding::GetConstructorObject(cx, global, rval);
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue