Update Rust

This commit is contained in:
Brian Anderson 2013-08-28 15:43:47 -07:00
parent 79956abb38
commit 1026556477
43 changed files with 252 additions and 150 deletions

View file

@ -12,12 +12,14 @@ pub trait JSValConvertible {
}
impl JSValConvertible for u32 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal {
unsafe {
RUST_UINT_TO_JSVAL(*self)
}
}
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<u32> {
unsafe {
Some(RUST_JSVAL_TO_INT(val) as u32)
@ -26,12 +28,14 @@ impl JSValConvertible for u32 {
}
impl JSValConvertible for i32 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal {
unsafe {
RUST_UINT_TO_JSVAL(*self as u32)
}
}
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<i32> {
unsafe {
Some(RUST_JSVAL_TO_INT(val) as i32)
@ -40,12 +44,14 @@ impl JSValConvertible for i32 {
}
impl JSValConvertible for u16 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal {
unsafe {
RUST_UINT_TO_JSVAL(*self as u32)
}
}
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<u16> {
unsafe {
Some(RUST_JSVAL_TO_INT(val) as u16)
@ -74,12 +80,14 @@ impl JSValConvertible for bool {
}
impl JSValConvertible for f32 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal {
unsafe {
RUST_DOUBLE_TO_JSVAL(*self as f64)
}
}
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<f32> {
unsafe {
Some(RUST_JSVAL_TO_DOUBLE(val) as f32)
@ -88,12 +96,14 @@ impl JSValConvertible for f32 {
}
impl JSValConvertible for f64 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal {
unsafe {
RUST_DOUBLE_TO_JSVAL(*self as f64)
}
}
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<f64> {
unsafe {
Some(RUST_JSVAL_TO_DOUBLE(val) as f64)