Updated to mozjs v0.7.1.

This commit is contained in:
Alan Jeffrey 2018-05-30 14:44:47 -05:00
parent 0786e34a3a
commit d0cc9d2cd5
13 changed files with 39 additions and 30 deletions

View file

@ -64,7 +64,7 @@ metrics = {path = "../metrics"}
mitochondria = "1.1.2"
mime = "0.2.1"
mime_guess = "1.8.0"
mozjs = { version = "0.6", features = ["promises"]}
mozjs = { version = "0.7.1", features = ["promises"]}
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
num-traits = "0.1.32"

View file

@ -361,7 +361,7 @@ class CGMethodCall(CGThing):
for i in range(0, distinguishingIndex)]
# Select the right overload from our set.
distinguishingArg = "args.get(%d)" % distinguishingIndex
distinguishingArg = "HandleValue::from_raw(args.get(%d))" % distinguishingIndex
def pickFirstSignature(condition, filterLambda):
sigs = filter(filterLambda, possibleSignatures)
@ -1284,7 +1284,7 @@ class CGArgumentConverter(CGThing):
}
replacementVariables = {
"val": string.Template("${args}.get(${index})").substitute(replacer),
"val": string.Template("HandleValue::from_raw(${args}.get(${index}))").substitute(replacer),
}
info = getJSToNativeConversionInfo(
@ -1328,7 +1328,7 @@ class CGArgumentConverter(CGThing):
else:
assert argument.optional
variadicConversion = {
"val": string.Template("${args}.get(variadicArg)").substitute(replacer),
"val": string.Template("HandleValue::from_raw(${args}.get(variadicArg))").substitute(replacer),
}
innerConverter = [instantiateJSToNativeConversionTemplate(
template, variadicConversion, declType, "slot")]
@ -3365,7 +3365,7 @@ class CGPerSignatureCall(CGThing):
return 'infallible' not in self.extendedAttributes
def wrap_return_value(self):
return wrapForType('args.rval()')
return wrapForType('MutableHandleValue::from_raw(args.rval())')
def define(self):
return (self.cgRoot.define() + "\n" + self.wrap_return_value())
@ -3516,7 +3516,7 @@ class CGSpecializedMethod(CGAbstractExternMethod):
self.descriptor, self.method),
pre="let this = &*this;\n"
"let args = &*args;\n"
"let argc = args._base.argc_;\n")
"let argc = args.argc_;\n")
@staticmethod
def makeNativeName(descriptor, method):
@ -3675,7 +3675,7 @@ if !v.is_object() {
return false;
}
rooted!(in(cx) let target_obj = v.to_object());
JS_SetProperty(cx, target_obj.handle(), %s as *const u8 as *const libc::c_char, args.get(0))
JS_SetProperty(cx, target_obj.handle(), %s as *const u8 as *const libc::c_char, HandleValue::from_raw(args.get(0)))
""" % (str_to_const_array(attrName), attrName, str_to_const_array(forwardToAttrName)))
@ -3693,7 +3693,7 @@ class CGSpecializedReplaceableSetter(CGSpecializedSetter):
assert all(ord(c) < 128 for c in name)
return CGGeneric("""\
JS_DefineProperty(cx, obj, %s as *const u8 as *const libc::c_char,
args.get(0), JSPROP_ENUMERATE, None, None)""" % name)
HandleValue::from_raw(args.get(0)), JSPROP_ENUMERATE, None, None)""" % name)
class CGMemberJITInfo(CGThing):
@ -5514,7 +5514,7 @@ if !JS_WrapObject(cx, element.handle_mut()) {
JS_SetPrototype(cx, element.handle(), prototype.handle());
(result).to_jsval(cx, args.rval());
(result).to_jsval(cx, MutableHandleValue::from_raw(args.rval()));
return true;
""" % self.descriptor.name)
else:

View file

@ -48,7 +48,7 @@ impl Reflector {
#[inline]
pub fn get_jsobject(&self) -> HandleObject {
// We're rooted, so it's safe to hand out a handle to object in Heap
unsafe { self.object.handle() }
unsafe { HandleObject::from_raw(self.object.handle()) }
}
/// Initialize the reflector. (May be called only once.)

View file

@ -798,7 +798,7 @@ impl<T> RootedTraceableBox<Heap<T>>
T: GCMethods + Copy,
{
pub fn handle(&self) -> Handle<T> {
unsafe { (*self.ptr).handle() }
unsafe { Handle::from_raw((*self.ptr).handle()) }
}
}

View file

@ -32,7 +32,7 @@ use js::glue::UnwrapObject;
use js::jsapi::{Heap, IsCallable, IsConstructor, HandleValueArray};
use js::jsapi::{JSAutoCompartment, JSContext, JSObject};
use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue};
use js::rust::{HandleObject, MutableHandleValue};
use js::rust::{HandleObject, HandleValue, MutableHandleValue};
use js::rust::wrappers::{JS_GetProperty, Construct1, JS_SameValue};
use microtask::Microtask;
use script_thread::ScriptThread;
@ -612,7 +612,7 @@ impl CustomElementReaction {
CustomElementReaction::Upgrade(ref definition) => upgrade_element(definition.clone(), element),
CustomElementReaction::Callback(ref callback, ref arguments) => {
// We're rooted, so it's safe to hand out a handle to objects in Heap
let arguments = arguments.iter().map(|arg| unsafe { arg.handle() }).collect();
let arguments = arguments.iter().map(|arg| unsafe { HandleValue::from_raw(arg.handle()) }).collect();
let _ = callback.Call_(&*element, arguments, ExceptionHandling::Report);
}
}

View file

@ -120,7 +120,7 @@ impl History {
PopStateEvent::dispatch_jsval(
self.window.upcast::<EventTarget>(),
&*self.window,
unsafe { self.state.handle() }
unsafe { HandleValue::from_raw(self.state.handle()) }
);
}

View file

@ -258,8 +258,10 @@ unsafe extern fn native_handler_callback(cx: *mut JSContext, argc: u32, vp: *mut
rooted!(in(cx) let v = *GetFunctionNativeReserved(args.callee(), SLOT_NATIVEHANDLER_TASK));
match v.to_int32() {
v if v == NativeHandlerTask::Resolve as i32 => handler.resolved_callback(cx, args.get(0)),
v if v == NativeHandlerTask::Reject as i32 => handler.rejected_callback(cx, args.get(0)),
v if v == NativeHandlerTask::Resolve as i32 =>
handler.resolved_callback(cx, HandleValue::from_raw(args.get(0))),
v if v == NativeHandlerTask::Reject as i32 =>
handler.rejected_callback(cx, HandleValue::from_raw(args.get(0))),
_ => panic!("unexpected native handler task value"),
};

View file

@ -522,6 +522,6 @@ impl JsTimerTask {
// always done via rooted JsTimers, which is safe.
#[allow(unsafe_code)]
fn collect_heap_args<'b>(&self, args: &'b [Heap<JSVal>]) -> Vec<HandleValue<'b>> {
args.iter().map(|arg| unsafe { arg.handle() }).collect()
args.iter().map(|arg| unsafe { HandleValue::from_raw(arg.handle()) }).collect()
}
}