Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d.

This commit is contained in:
Ms2ger 2014-12-17 10:42:52 +01:00 committed by Josh Matthews
parent b8900782b0
commit 466faac2a5
223 changed files with 4414 additions and 4105 deletions

View file

@ -425,7 +425,7 @@ def typeNeedsRooting(type, descriptorProvider):
def union_native_type(t):
name = t.unroll().name
return 'UnionTypes::%s::%s' % (name, name)
return 'UnionTypes::%s' % name
def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
@ -741,7 +741,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
if defaultValue is not None:
assert(defaultValue.type.tag() == IDLType.Tags.domstring)
default = "%sValues::%s" % (enum, getEnumValueName(defaultValue.value))
default = "%s::%s" % (enum, getEnumValueName(defaultValue.value))
else:
default = None
@ -1419,11 +1419,11 @@ class CGNamespace(CGWrapper):
def DOMClass(descriptor):
protoList = ['PrototypeList::id::' + proto for proto in descriptor.prototypeChain]
# Pad out the list to the right length with IDCount so we
# guarantee that all the lists are the same length. IDCount
# Pad out the list to the right length with id::Count so we
# guarantee that all the lists are the same length. id::Count
# is never the ID of any prototype, so it's safe to use as
# padding.
protoList.extend(['PrototypeList::id::IDCount'] * (descriptor.config.maxProtoChainLength - len(protoList)))
protoList.extend(['PrototypeList::id::Count'] * (descriptor.config.maxProtoChainLength - len(protoList)))
prototypeChainString = ', '.join(protoList)
return """DOMClass {
interface_chain: [ %s ],
@ -1673,7 +1673,7 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
'dom::bindings::codegen::PrototypeList',
'dom::bindings::conversions::FromJSValConvertible',
'dom::bindings::conversions::ToJSValConvertible',
'dom::bindings::conversions::Default',
'dom::bindings::conversions::StringificationBehavior::Default',
'dom::bindings::error::throw_not_in_union',
'dom::bindings::js::JS',
'dom::types::*',
@ -1693,14 +1693,12 @@ def UnionTypes(descriptors, dictionaries, callbacks, config):
name = str(t)
if not name in unionStructs:
provider = descriptor or config.getDescriptorProvider()
unionStructs[name] = CGNamespace(name,
CGImports(CGList([
CGUnionStruct(t, provider),
CGUnionConversionStruct(t, provider)
]), [], imports),
public=True)
unionStructs[name] = CGList([
CGUnionStruct(t, provider),
CGUnionConversionStruct(t, provider)
])
return CGList(SortedDictValues(unionStructs), "\n\n")
return CGImports(CGList(SortedDictValues(unionStructs), "\n\n"), [], imports)
class Argument():
@ -1889,7 +1887,7 @@ class CGIDLInterface(CGThing):
}
return string.Template("""
impl IDLInterface for ${type} {
fn get_prototype_id(_: Option<${type}>) -> PrototypeList::id::ID {
fn get_prototype_id(_: Option<${type}>) -> PrototypeList::id {
PrototypeList::id::${type}
}
fn get_prototype_depth(_: Option<${type}>) -> uint {
@ -2753,35 +2751,36 @@ def getEnumValueName(value):
class CGEnum(CGThing):
def __init__(self, enum):
CGThing.__init__(self)
decl = """
#[repr(uint)]
#[deriving(PartialEq)]
#[jstraceable]
pub enum %s {
%s
}
""" % (enum.identifier.name, ",\n ".join(map(getEnumValueName, enum.values())))
inner = """
use dom::bindings::conversions::ToJSValConvertible;
use js::jsapi::JSContext;
use js::jsval::JSVal;
#[repr(uint)]
#[deriving(PartialEq)]
#[jstraceable]
pub enum valuelist {
%s
}
pub const strings: &'static [&'static str] = &[
%s,
];
impl ToJSValConvertible for valuelist {
impl ToJSValConvertible for super::%s {
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
strings[*self as uint].to_string().to_jsval(cx)
}
}
""" % (",\n ".join(map(getEnumValueName, enum.values())),
",\n ".join(['"%s"' % val for val in enum.values()]))
""" % (",\n ".join(['"%s"' % val for val in enum.values()]), enum.identifier.name)
self.cgRoot = CGList([
CGGeneric(decl),
CGNamespace.build([enum.identifier.name + "Values"],
CGIndenter(CGGeneric(inner)), public=True),
CGGeneric("pub type %s = self::%sValues::valuelist;\n" %
(enum.identifier.name, enum.identifier.name)),
])
def define(self):
@ -2876,7 +2875,7 @@ class CGUnionStruct(CGThing):
" e%s(%s)," % (v["name"], v["typeName"]) for v in templateVars
]
enumConversions = [
" e%s(ref inner) => inner.to_jsval(cx)," % v["name"] for v in templateVars
" %s::e%s(ref inner) => inner.to_jsval(cx)," % (self.type, v["name"]) for v in templateVars
]
# XXXManishearth The following should be #[must_root],
# however we currently allow it till #2661 is fixed
@ -2922,9 +2921,9 @@ class CGUnionConversionStruct(CGThing):
return (
"match %s::TryConvertTo%s(cx, value) {\n"
" Err(_) => return Err(()),\n"
" Ok(Some(value)) => return Ok(e%s(value)),\n"
" Ok(Some(value)) => return Ok(%s::e%s(value)),\n"
" Ok(None) => (),\n"
"}\n") % (self.type, name, name)
"}\n") % (self.type, name, self.type, name)
typeNames = [get_name(memberType) for memberType in interfaceMemberTypes]
interfaceObject = CGList(CGGeneric(get_match(typeName)) for typeName in typeNames)
@ -2990,9 +2989,9 @@ class CGUnionConversionStruct(CGThing):
match = (
"match %s::TryConvertTo%s(cx, value) {\n"
" Err(_) => return Err(()),\n"
" Ok(Some(value)) => return Ok(e%s(value)),\n"
" Ok(Some(value)) => return Ok(%s::e%s(value)),\n"
" Ok(None) => (),\n"
"}\n") % (self.type, name, name)
"}\n") % (self.type, name, self.type, name)
conversions.append(CGGeneric(match))
names.append(name)
@ -4182,8 +4181,8 @@ class CGDescriptor(CGThing):
def define(self):
return self.cgRoot.define()
class CGNamespacedEnum(CGThing):
def __init__(self, namespace, enumName, names, values, comment="", deriving=""):
class CGNonNamespacedEnum(CGThing):
def __init__(self, enumName, names, values, comment="", deriving=""):
if not values:
values = []
@ -4198,7 +4197,7 @@ class CGNamespacedEnum(CGThing):
entries.append(entry)
# Append a Count.
entries.append(enumName + 'Count = ' + str(len(entries)))
entries.append('Count = ' + str(len(entries)))
# Indent.
entries = [' ' + e for e in entries]
@ -4212,9 +4211,6 @@ class CGNamespacedEnum(CGThing):
# Add some whitespace padding.
curr = CGWrapper(curr, pre='\n',post='\n')
# Add the namespace.
curr = CGNamespace(namespace, curr, public=True)
# Add the typedef
#typedef = '\ntypedef %s::%s %s;\n\n' % (namespace, enumName, enumName)
#curr = CGList([curr, CGGeneric(typedef)])
@ -4504,23 +4500,25 @@ class CGBindingRoot(CGThing):
'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}',
'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}',
'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}',
'dom::bindings::utils::{HasPropertyOnPrototype, IntVal, UintVal}',
'dom::bindings::utils::HasPropertyOnPrototype',
'dom::bindings::utils::{Reflectable}',
'dom::bindings::utils::{squirrel_away_unique}',
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
'dom::bindings::utils::get_dictionary_property',
'dom::bindings::utils::{NativeProperties, NativePropertyHooks}',
'dom::bindings::utils::ConstantVal::{IntVal, UintVal}',
'dom::bindings::trace::JSTraceable',
'dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction}',
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
'dom::bindings::callback::{WrapCallThisObject}',
'dom::bindings::conversions::{FromJSValConvertible, ToJSValConvertible}',
'dom::bindings::conversions::IDLInterface',
'dom::bindings::conversions::{Default, Empty}',
'dom::bindings::conversions::jsid_to_str',
'dom::bindings::conversions::StringificationBehavior::{Default, Empty}',
'dom::bindings::codegen::{PrototypeList, RegisterBindings, UnionTypes}',
'dom::bindings::codegen::Bindings::*',
'dom::bindings::error::{FailureUnknown, Fallible, Error, ErrorResult}',
'dom::bindings::error::{Fallible, Error, ErrorResult}',
'dom::bindings::error::Error::FailureUnknown',
'dom::bindings::error::throw_dom_exception',
'dom::bindings::error::throw_type_error',
'dom::bindings::proxyhandler',
@ -5137,8 +5135,8 @@ class GlobalGenRoots():
return CGList([
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
CGNamespacedEnum('id', 'ID', protos, [0], deriving="PartialEq"),
CGNamespacedEnum('proxies', 'Proxy', proxies, [0], deriving="PartialEq"),
CGNonNamespacedEnum('id', protos, [0], deriving="PartialEq"),
CGNonNamespacedEnum('proxies', proxies, [0], deriving="PartialEq"),
])

View file

@ -37,7 +37,7 @@ use dom::bindings::codegen::PrototypeList;
// remove Option<Self> arguments.
pub trait IDLInterface {
/// Returns the prototype ID.
fn get_prototype_id(_: Option<Self>) -> PrototypeList::id::ID;
fn get_prototype_id(_: Option<Self>) -> PrototypeList::id;
/// Returns the prototype depth, i.e., the number of interfaces this
/// interface inherits from.
fn get_prototype_depth(_: Option<Self>) -> uint;
@ -256,7 +256,7 @@ pub enum StringificationBehavior {
impl default::Default for StringificationBehavior {
fn default() -> StringificationBehavior {
Default
StringificationBehavior::Default
}
}
@ -283,7 +283,7 @@ pub fn jsid_to_str(cx: *mut JSContext, id: jsid) -> DOMString {
impl FromJSValConvertible<StringificationBehavior> for DOMString {
fn from_jsval(cx: *mut JSContext, value: JSVal, nullBehavior: StringificationBehavior) -> Result<DOMString, ()> {
if nullBehavior == Empty && value.is_null() {
if nullBehavior == StringificationBehavior::Empty && value.is_null() {
Ok("".to_string())
} else {
let jsstr = unsafe { JS_ValueToString(cx, value) };

View file

@ -7,6 +7,10 @@
//! This module contains smart pointers to global scopes, to simplify writing
//! code that works in workers as well as window scopes.
pub use self::GlobalRef::*;
pub use self::GlobalRoot::*;
pub use self::GlobalField::*;
use dom::bindings::conversions::FromJSValConvertible;
use dom::bindings::js::{JS, JSRef, Root};
use dom::bindings::utils::{Reflectable, Reflector};

View file

@ -4,9 +4,9 @@
//! The `ByteString` struct.
use std::from_str::FromStr;
use std::hash::{Hash, sip};
use std::str;
use std::str::FromStr;
/// Encapsulates the IDL `ByteString` type.
#[deriving(Clone,Eq,PartialEq)]
@ -89,31 +89,31 @@ impl ByteString {
SPHT // SP or HT
}
let ByteString(ref vec) = *self;
let mut prev = Other; // The previous character
let mut prev = PreviousCharacter::Other; // The previous character
vec.iter().all(|&x| {
// http://tools.ietf.org/html/rfc2616#section-2.2
match x {
13 => { // CR
if prev == Other || prev == SPHT {
prev = CR;
if prev == PreviousCharacter::Other || prev == PreviousCharacter::SPHT {
prev = PreviousCharacter::CR;
true
} else {
false
}
},
10 => { // LF
if prev == CR {
prev = LF;
if prev == PreviousCharacter::CR {
prev = PreviousCharacter::LF;
true
} else {
false
}
},
32 => { // SP
if prev == LF || prev == SPHT {
prev = SPHT;
if prev == PreviousCharacter::LF || prev == PreviousCharacter::SPHT {
prev = PreviousCharacter::SPHT;
true
} else if prev == Other {
} else if prev == PreviousCharacter::Other {
// Counts as an Other here, since it's not preceded by a CRLF
// SP is not a CTL, so it can be used anywhere
// though if used immediately after a CR the CR is invalid
@ -124,8 +124,8 @@ impl ByteString {
}
},
9 => { // HT
if prev == LF || prev == SPHT {
prev = SPHT;
if prev == PreviousCharacter::LF || prev == PreviousCharacter::SPHT {
prev = PreviousCharacter::SPHT;
true
} else {
false
@ -133,8 +133,8 @@ impl ByteString {
},
0...31 | 127 => false, // CTLs
x if x > 127 => false, // non ASCII
_ if prev == Other || prev == SPHT => {
prev = Other;
_ if prev == PreviousCharacter::Other || prev == PreviousCharacter::SPHT => {
prev = PreviousCharacter::Other;
true
},
_ => false // Previous character was a CR/LF but not part of the [CRLF] (SP|HT) rule

View file

@ -124,7 +124,7 @@ pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<DOMClass, ()> {
/// not a reflector for a DOM object of the given type (as defined by the
/// proto_id and proto_depth).
pub fn unwrap_jsmanaged<T: Reflectable>(mut obj: *mut JSObject,
proto_id: PrototypeList::id::ID,
proto_id: PrototypeList::id,
proto_depth: uint) -> Result<JS<T>, ()> {
unsafe {
let dom_class = get_dom_class(obj).or_else(|_| {
@ -212,11 +212,11 @@ impl ConstantSpec {
/// Returns a `JSVal` that represents the value of this `ConstantSpec`.
pub fn get_value(&self) -> JSVal {
match self.value {
NullVal => NullValue(),
IntVal(i) => Int32Value(i),
UintVal(u) => UInt32Value(u),
DoubleVal(d) => DoubleValue(d),
BoolVal(b) => BooleanValue(b),
ConstantVal::NullVal => NullValue(),
ConstantVal::IntVal(i) => Int32Value(i),
ConstantVal::UintVal(u) => UInt32Value(u),
ConstantVal::DoubleVal(d) => DoubleValue(d),
ConstantVal::BoolVal(b) => BooleanValue(b),
}
}
}
@ -234,7 +234,7 @@ pub struct NativePropertyHooks {
pub struct DOMClass {
/// A list of interfaces that this object implements, in order of decreasing
/// derivedness.
pub interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH],
pub interface_chain: [PrototypeList::id, ..MAX_PROTO_CHAIN_LENGTH],
/// The NativePropertyHooks for the interface associated with this class.
pub native_hooks: &'static NativePropertyHooks,
@ -421,7 +421,7 @@ pub unsafe extern fn ThrowingConstructor(cx: *mut JSContext, _argc: c_uint, _vp:
/// Construct and cache the ProtoOrIfaceArray for the given global.
/// Fails if the argument is not a DOM global.
pub fn initialize_global(global: *mut JSObject) {
let protoArray = box () ([0 as *mut JSObject, ..PrototypeList::id::IDCount as uint]);
let protoArray = box () ([0 as *mut JSObject, ..PrototypeList::id::Count as uint]);
unsafe {
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
let box_ = squirrel_away_unique(protoArray);
@ -722,10 +722,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
let mut non_qname_colons = false;
let mut seen_colon = false;
match iter.next() {
None => return InvalidXMLName,
None => return XMLName::InvalidXMLName,
Some(c) => {
if !is_valid_start(c) {
return InvalidXMLName;
return XMLName::InvalidXMLName;
}
if c == ':' {
non_qname_colons = true;
@ -735,7 +735,7 @@ pub fn xml_name_type(name: &str) -> XMLName {
for c in name.chars() {
if !is_valid_continuation(c) {
return InvalidXMLName;
return XMLName::InvalidXMLName;
}
if c == ':' {
match seen_colon {
@ -746,7 +746,7 @@ pub fn xml_name_type(name: &str) -> XMLName {
}
match non_qname_colons {
false => QName,
true => Name
false => XMLName::QName,
true => XMLName::Name
}
}