mirror of
https://github.com/servo/servo.git
synced 2025-10-13 23:10:20 +01:00
Update Rust.
This commit is contained in:
parent
3644d0272c
commit
eaedeb07cb
184 changed files with 643 additions and 657 deletions
|
@ -85,7 +85,7 @@ pub fn GetJSObjectFromCallback<T: CallbackContainer>(callback: &T) -> *JSObject
|
|||
|
||||
pub fn WrapCallThisObject<T: 'static + CallbackContainer + Reflectable>(cx: *JSContext,
|
||||
_scope: *JSObject,
|
||||
p: ~T) -> *JSObject {
|
||||
p: Box<T>) -> *JSObject {
|
||||
let obj = GetJSObjectFromCallback(p);
|
||||
assert!(obj.is_not_null());
|
||||
|
||||
|
|
|
@ -1755,10 +1755,10 @@ class CGWrapMethod(CGAbstractMethod):
|
|||
assert descriptor.interface.hasInterfacePrototypeObject()
|
||||
if not descriptor.createGlobal:
|
||||
args = [Argument('*JSContext', 'aCx'), Argument('&JSRef<Window>', 'aScope'),
|
||||
Argument("~" + descriptor.concreteType, 'aObject', mutable=True)]
|
||||
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)]
|
||||
else:
|
||||
args = [Argument('*JSContext', 'aCx'),
|
||||
Argument("~" + descriptor.concreteType, 'aObject', mutable=True)]
|
||||
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)]
|
||||
retval = 'JS<%s>' % descriptor.concreteType
|
||||
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True)
|
||||
|
||||
|
@ -2609,7 +2609,7 @@ impl ToJSValConvertible for valuelist {
|
|||
}
|
||||
}
|
||||
""" % (",\n ".join(map(getEnumValueName, enum.values())),
|
||||
",\n ".join(['&"%s"' % val for val in enum.values()]))
|
||||
",\n ".join(['"%s"' % val for val in enum.values()]))
|
||||
|
||||
self.cgRoot = CGList([
|
||||
CGNamespace.build([enum.identifier.name + "Values"],
|
||||
|
@ -3740,7 +3740,7 @@ class CGAbstractClassHook(CGAbstractExternMethod):
|
|||
|
||||
def finalizeHook(descriptor, hookName, context):
|
||||
release = """let val = JS_GetReservedSlot(obj, dom_object_slot(obj));
|
||||
let _: ~%s = cast::transmute(val.to_private());
|
||||
let _: Box<%s> = cast::transmute(val.to_private());
|
||||
debug!("%s finalize: {:p}", this);
|
||||
""" % (descriptor.concreteType, descriptor.concreteType)
|
||||
return release
|
||||
|
@ -4221,7 +4221,7 @@ class CGBindingRoot(CGThing):
|
|||
'dom::bindings::js::{OptionalRootable, OptionalRootedRootable, ResultRootable}',
|
||||
'dom::bindings::js::{OptionalRootedReference, OptionalOptionalRootedRootable}',
|
||||
'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}',
|
||||
'dom::bindings::utils::{ConstantSpec, cx_for_dom_object, Default}',
|
||||
'dom::bindings::utils::{ConstantSpec, cx_for_dom_object}',
|
||||
'dom::bindings::utils::{dom_object_slot, DOM_OBJECT_SLOT, DOMClass}',
|
||||
'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}',
|
||||
'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}',
|
||||
|
@ -4258,7 +4258,6 @@ class CGBindingRoot(CGThing):
|
|||
'std::cast',
|
||||
'std::cmp',
|
||||
'std::ptr',
|
||||
'std::slice',
|
||||
'std::str',
|
||||
'std::num',
|
||||
])
|
||||
|
@ -4649,7 +4648,7 @@ class CGCallback(CGClass):
|
|||
|
||||
# And now insert our template argument.
|
||||
argsWithoutThis = list(args)
|
||||
args.insert(0, Argument("~T", "thisObj"))
|
||||
args.insert(0, Argument("Box<T>", "thisObj"))
|
||||
|
||||
# And the self argument
|
||||
method.args.insert(0, Argument(None, "&self"))
|
||||
|
@ -4799,7 +4798,7 @@ class CallbackMember(CGNativeMember):
|
|||
if self.argCount > 0:
|
||||
replacements["argCount"] = self.argCountStr
|
||||
replacements["argvDecl"] = string.Template(
|
||||
"let mut argv = slice::from_elem(${argCount}, UndefinedValue());\n"
|
||||
"let mut argv = Vec::from_elem(${argCount}, UndefinedValue());\n"
|
||||
).substitute(replacements)
|
||||
else:
|
||||
# Avoid weird 0-sized arrays
|
||||
|
@ -4886,7 +4885,7 @@ class CallbackMember(CGNativeMember):
|
|||
result = argval
|
||||
prepend = ""
|
||||
|
||||
conversion = prepend + wrapForType("argv[%s]" % jsvalIndex,
|
||||
conversion = prepend + wrapForType("*argv.get_mut(%s)" % jsvalIndex,
|
||||
result=result,
|
||||
successCode="continue;" if arg.variadic else "break;")
|
||||
if arg.variadic:
|
||||
|
@ -4975,7 +4974,7 @@ class CallbackMethod(CallbackMember):
|
|||
"getCallable": self.getCallableDecl()
|
||||
}
|
||||
if self.argCount > 0:
|
||||
replacements["argv"] = "&argv[0]"
|
||||
replacements["argv"] = "argv.as_ptr()"
|
||||
replacements["argc"] = "argc"
|
||||
else:
|
||||
replacements["argv"] = "nullptr"
|
||||
|
|
|
@ -49,7 +49,6 @@ use script_task::StackRoots;
|
|||
use std::cast;
|
||||
use std::cell::RefCell;
|
||||
use std::kinds::marker::ContravariantLifetime;
|
||||
use std::local_data;
|
||||
|
||||
/// A type that represents a JS-owned value that is rooted for the lifetime of this value.
|
||||
/// Importantly, it requires explicit rooting in order to interact with the inner value.
|
||||
|
@ -94,12 +93,10 @@ impl<T: Reflectable> Temporary<T> {
|
|||
|
||||
/// Create a stack-bounded root for this value.
|
||||
pub fn root<'a, 'b>(self) -> Root<'a, 'b, T> {
|
||||
local_data::get(StackRoots, |opt| {
|
||||
let collection = opt.unwrap();
|
||||
unsafe {
|
||||
(**collection).new_root(&self.inner)
|
||||
}
|
||||
})
|
||||
let collection = StackRoots.get().unwrap();
|
||||
unsafe {
|
||||
(**collection).new_root(&self.inner)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn inner(&self) -> JS<T> {
|
||||
|
@ -162,12 +159,10 @@ impl<T: Reflectable> JS<T> {
|
|||
|
||||
/// Root this JS-owned value to prevent its collection as garbage.
|
||||
pub fn root<'a, 'b>(&self) -> Root<'a, 'b, T> {
|
||||
local_data::get(StackRoots, |opt| {
|
||||
let collection = opt.unwrap();
|
||||
unsafe {
|
||||
(**collection).new_root(self)
|
||||
}
|
||||
})
|
||||
let collection = StackRoots.get().unwrap();
|
||||
unsafe {
|
||||
(**collection).new_root(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *JSObject,
|
|||
}
|
||||
}
|
||||
|
||||
pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *T {
|
||||
pub unsafe fn squirrel_away_unique<T>(x: Box<T>) -> *T {
|
||||
cast::transmute(x)
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: c_uint, _vp: *mut JSVa
|
|||
}
|
||||
|
||||
pub fn initialize_global(global: *JSObject) {
|
||||
let protoArray = ~([0 as *JSObject, ..PrototypeList::id::IDCount as uint]);
|
||||
let protoArray = box () ([0 as *JSObject, ..PrototypeList::id::IDCount as uint]);
|
||||
unsafe {
|
||||
let box_ = squirrel_away_unique(protoArray);
|
||||
JS_SetReservedSlot(global,
|
||||
|
@ -390,9 +390,9 @@ pub trait Reflectable {
|
|||
}
|
||||
|
||||
pub fn reflect_dom_object<T: Reflectable>
|
||||
(obj: ~T,
|
||||
(obj: Box<T>,
|
||||
window: &JSRef<window::Window>,
|
||||
wrap_fn: extern "Rust" fn(*JSContext, &JSRef<window::Window>, ~T) -> JS<T>)
|
||||
wrap_fn: extern "Rust" fn(*JSContext, &JSRef<window::Window>, Box<T>) -> JS<T>)
|
||||
-> Temporary<T> {
|
||||
Temporary::new(wrap_fn(window.deref().get_cx(), window, obj))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue