aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-01-31 04:27:49 -0700
committerbors-servo <metajack+bors@gmail.com>2015-01-31 04:27:49 -0700
commit83e196c4c6a761757d821abfd1ab539704d22454 (patch)
tree00c6275b087f909d3fe8bb248f5f0eb82e6e5473 /components
parent2010fbf0ddabdaf3bcb52c5f2075e7d994fc63ec (diff)
parent5c9b1019a99c52171fd6e2a36ecd45902f6f3b0e (diff)
downloadservo-83e196c4c6a761757d821abfd1ab539704d22454.tar.gz
servo-83e196c4c6a761757d821abfd1ab539704d22454.zip
auto merge of #4792 : Manishearth/servo/old_impl, r=Ms2ger
Diffstat (limited to 'components')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py2
-rw-r--r--components/script/dom/bindings/conversions.rs51
-rw-r--r--components/script/lib.rs1
-rw-r--r--components/util/lib.rs1
-rw-r--r--components/util/range.rs26
5 files changed, 47 insertions, 34 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 795204466df..6fa1b75fcd4 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -3016,7 +3016,7 @@ class CGUnionConversionStruct(CGThing):
post="\n}")
return CGWrapper(
CGIndenter(method),
- pre="impl FromJSValConvertible<()> for %s {\n" % self.type,
+ pre="impl FromJSValConvertible for %s {\ntype Config = ();\n" % self.type,
post="\n}")
def try_method(self, t):
diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs
index bf805a35fbf..d7182f8993f 100644
--- a/components/script/dom/bindings/conversions.rs
+++ b/components/script/dom/bindings/conversions.rs
@@ -49,12 +49,13 @@ pub trait ToJSValConvertible {
}
/// A trait to convert `JSVal`s to Rust types.
-pub trait FromJSValConvertible<T> {
+pub trait FromJSValConvertible {
+ type Config;
/// Convert `val` to type `Self`.
/// Optional configuration of type `T` can be passed as the `option`
/// argument.
/// If it returns `Err(())`, a JSAPI exception is pending.
- fn from_jsval(cx: *mut JSContext, val: JSVal, option: T) -> Result<Self, ()>;
+ fn from_jsval(cx: *mut JSContext, val: JSVal, option: Self::Config) -> Result<Self, ()>;
}
@@ -92,7 +93,8 @@ impl ToJSValConvertible for bool {
}
}
-impl FromJSValConvertible<()> for bool {
+impl FromJSValConvertible for bool {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<bool, ()> {
let result = unsafe { convert_from_jsval(cx, val, JS_ValueToBoolean) };
result.map(|b| b != 0)
@@ -105,7 +107,8 @@ impl ToJSValConvertible for i8 {
}
}
-impl FromJSValConvertible<()> for i8 {
+impl FromJSValConvertible for i8 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<i8, ()> {
let result = unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) };
result.map(|v| v as i8)
@@ -118,7 +121,8 @@ impl ToJSValConvertible for u8 {
}
}
-impl FromJSValConvertible<()> for u8 {
+impl FromJSValConvertible for u8 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<u8, ()> {
let result = unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) };
result.map(|v| v as u8)
@@ -131,7 +135,8 @@ impl ToJSValConvertible for i16 {
}
}
-impl FromJSValConvertible<()> for i16 {
+impl FromJSValConvertible for i16 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<i16, ()> {
let result = unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) };
result.map(|v| v as i16)
@@ -144,7 +149,8 @@ impl ToJSValConvertible for u16 {
}
}
-impl FromJSValConvertible<()> for u16 {
+impl FromJSValConvertible for u16 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<u16, ()> {
unsafe { convert_from_jsval(cx, val, JS_ValueToUint16) }
}
@@ -156,7 +162,8 @@ impl ToJSValConvertible for i32 {
}
}
-impl FromJSValConvertible<()> for i32 {
+impl FromJSValConvertible for i32 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<i32, ()> {
unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) }
}
@@ -168,7 +175,8 @@ impl ToJSValConvertible for u32 {
}
}
-impl FromJSValConvertible<()> for u32 {
+impl FromJSValConvertible for u32 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<u32, ()> {
unsafe { convert_from_jsval(cx, val, JS_ValueToECMAUint32) }
}
@@ -182,7 +190,8 @@ impl ToJSValConvertible for i64 {
}
}
-impl FromJSValConvertible<()> for i64 {
+impl FromJSValConvertible for i64 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<i64, ()> {
unsafe { convert_from_jsval(cx, val, JS_ValueToInt64) }
}
@@ -196,7 +205,8 @@ impl ToJSValConvertible for u64 {
}
}
-impl FromJSValConvertible<()> for u64 {
+impl FromJSValConvertible for u64 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<u64, ()> {
unsafe { convert_from_jsval(cx, val, JS_ValueToUint64) }
}
@@ -210,7 +220,8 @@ impl ToJSValConvertible for f32 {
}
}
-impl FromJSValConvertible<()> for f32 {
+impl FromJSValConvertible for f32 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<f32, ()> {
let result = unsafe { convert_from_jsval(cx, val, JS_ValueToNumber) };
result.map(|f| f as f32)
@@ -225,7 +236,8 @@ impl ToJSValConvertible for f64 {
}
}
-impl FromJSValConvertible<()> for f64 {
+impl FromJSValConvertible for f64 {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result<f64, ()> {
unsafe { convert_from_jsval(cx, val, JS_ValueToNumber) }
}
@@ -285,7 +297,8 @@ pub fn jsid_to_str(cx: *mut JSContext, id: jsid) -> DOMString {
}
}
-impl FromJSValConvertible<StringificationBehavior> for DOMString {
+impl FromJSValConvertible for DOMString {
+ type Config = StringificationBehavior;
fn from_jsval(cx: *mut JSContext, value: JSVal,
null_behavior: StringificationBehavior)
-> Result<DOMString, ()> {
@@ -317,7 +330,8 @@ impl ToJSValConvertible for ByteString {
}
}
-impl FromJSValConvertible<()> for ByteString {
+impl FromJSValConvertible for ByteString {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, value: JSVal, _option: ()) -> Result<ByteString, ()> {
unsafe {
let string = JS_ValueToString(cx, value);
@@ -462,7 +476,8 @@ pub fn unwrap_jsmanaged<T>(mut obj: *mut JSObject) -> Result<JS<T>, ()>
}
}
-impl<T: Reflectable+IDLInterface> FromJSValConvertible<()> for JS<T> {
+impl<T: Reflectable+IDLInterface> FromJSValConvertible for JS<T> {
+ type Config = ();
fn from_jsval(_cx: *mut JSContext, value: JSVal, _option: ()) -> Result<JS<T>, ()> {
if !value.is_object() {
return Err(());
@@ -498,8 +513,8 @@ impl<T: ToJSValConvertible> ToJSValConvertible for Option<T> {
}
}
-#[old_impl_check]
-impl<X: default::Default, T: FromJSValConvertible<X>> FromJSValConvertible<()> for Option<T> {
+impl<X: default::Default, T: FromJSValConvertible<Config=X>> FromJSValConvertible for Option<T> {
+ type Config = ();
fn from_jsval(cx: *mut JSContext, value: JSVal, _: ()) -> Result<Option<T>, ()> {
if value.is_null_or_undefined() {
Ok(None)
diff --git a/components/script/lib.rs b/components/script/lib.rs
index 5ffaa96b657..fdc69fd73f9 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(unsafe_destructor, plugin, box_syntax, int_uint)]
-#![feature(old_impl_check)]
#![deny(unsafe_blocks)]
#![deny(unused_imports)]
diff --git a/components/util/lib.rs b/components/util/lib.rs
index bceab7a3014..3736b6a5a09 100644
--- a/components/util/lib.rs
+++ b/components/util/lib.rs
@@ -5,7 +5,6 @@
#![feature(unsafe_destructor)]
#![feature(plugin)]
#![feature(int_uint)]
-#![feature(old_impl_check)]
#![feature(box_syntax)]
#![deny(unused_imports)]
diff --git a/components/util/range.rs b/components/util/range.rs
index fbf14f38400..8c217beb218 100644
--- a/components/util/range.rs
+++ b/components/util/range.rs
@@ -9,12 +9,14 @@ use std::num;
use std::num::Int;
/// An index type to be used by a `Range`
-pub trait RangeIndex<T>: Int + fmt::Show {
- fn new(x: T) -> Self;
- fn get(self) -> T;
+pub trait RangeIndex: Int + fmt::Show {
+ type Index;
+ fn new(x: Self::Index) -> Self;
+ fn get(self) -> Self::Index;
}
-impl RangeIndex<int> for int {
+impl RangeIndex for int {
+ type Index = int;
#[inline]
fn new(x: int) -> int { x }
@@ -37,7 +39,8 @@ macro_rules! int_range_index {
}
}
- impl RangeIndex<$T> for $Self {
+ impl RangeIndex for $Self {
+ type Index = $T;
#[inline]
fn new(x: $T) -> $Self {
$Self(x)
@@ -191,8 +194,7 @@ pub struct Range<I> {
length: I,
}
-#[old_impl_check]
-impl<I: RangeIndex<T>, T> fmt::Show for Range<I> {
+impl<I: RangeIndex> fmt::Show for Range<I> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "[{:?} .. {:?})", self.begin(), self.end())
}
@@ -203,11 +205,11 @@ pub struct EachIndex<T, I> {
it: iter::Range<T>,
}
-pub fn each_index<T: Int, I: RangeIndex<T>>(start: I, stop: I) -> EachIndex<T, I> {
+pub fn each_index<T: Int, I: RangeIndex<Index=T>>(start: I, stop: I) -> EachIndex<T, I> {
EachIndex { it: iter::range(start.get(), stop.get()) }
}
-impl<T: Int, I: RangeIndex<T>> Iterator for EachIndex<T, I> {
+impl<T: Int, I: RangeIndex<Index=T>> Iterator for EachIndex<T, I> {
type Item = I;
#[inline]
@@ -221,8 +223,7 @@ impl<T: Int, I: RangeIndex<T>> Iterator for EachIndex<T, I> {
}
}
-#[old_impl_check]
-impl<I: RangeIndex<T>, T> Range<I> {
+impl<I: RangeIndex> Range<I> {
/// Create a new range from beginning and length offsets. This could be
/// denoted as `[begin, begin + length)`.
///
@@ -359,8 +360,7 @@ impl<I: RangeIndex<T>, T> Range<I> {
}
/// Methods for `Range`s with indices based on integer values
-#[old_impl_check]
-impl<T: Int, I: RangeIndex<T>> Range<I> {
+impl<T: Int, I: RangeIndex<Index=T>> Range<I> {
/// Returns an iterater that increments over `[begin, end)`.
#[inline]
pub fn each_index(&self) -> EachIndex<T, I> {