Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to rustc 1.0.0-dev (47551b574 2015-04-14) (built 2015-03-18) #143

Merged
merged 2 commits into from May 5, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Upgrade to rustc 1.0.0-dev (47551b574 2015-04-14) (built 2015-03-18)

  • Loading branch information
SimonSapin committed Apr 23, 2015
commit 8c2662885fdeef751ae613df23143ca8b26a0e88
@@ -14,3 +14,5 @@ git = "https://github.com/servo/mozjs"

[dependencies]
libc = "*"
rustc-serialize = "*"
log = "*"
@@ -24,18 +24,18 @@ pub struct ProxyTraps {
pub get: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut JSObject, jsid, *mut JSVal) -> bool>,
pub set: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut JSObject, jsid, bool, *mut JSVal) -> bool>,
pub keys: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut AutoIdVector) -> bool>,
pub iterate: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, uint, *mut JSVal) -> bool>,
pub iterate: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, usize, *mut JSVal) -> bool>,

pub call: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, uint, *mut JSVal) -> bool>,
pub construct: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, uint, *mut JSVal, *mut JSVal) -> bool>,
pub call: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, usize, *mut JSVal) -> bool>,
pub construct: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, usize, *mut JSVal, *mut JSVal) -> bool>,
pub nativeCall: *const u8, //XXX need a representation for IsAcceptableThis, NativeImpl, and CallArgs
pub hasInstance: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut JSVal, *mut bool) -> bool>,
pub typeOf: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject) -> uint>, //XXX JSType enum
pub objectClassIs: Option<unsafe extern "C" fn(*mut JSObject, uint, *mut JSContext) -> bool>, //XXX ESClassValue enum
pub typeOf: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject) -> usize>, //XXX JSType enum
pub objectClassIs: Option<unsafe extern "C" fn(*mut JSObject, usize, *mut JSContext) -> bool>, //XXX ESClassValue enum
pub obj_toString: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject) -> *mut JSString>,
pub fun_toString: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, uint) -> *mut JSString>,
pub fun_toString: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, usize) -> *mut JSString>,
//regexp_toShared: *u8,
pub defaultValue: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, uint, *mut JSVal) -> bool>, //XXX JSType enum
pub defaultValue: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, usize, *mut JSVal) -> bool>, //XXX JSType enum
pub iteratorNext: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut JSVal) -> bool>,
pub finalize: Option<unsafe extern "C" fn(*mut JSFreeOp, *mut JSObject)>,
pub getElementIfPresent: Option<unsafe extern "C" fn(*mut JSContext, *mut JSObject, *mut JSObject, u32, *mut JSVal, *mut bool) -> bool>,
@@ -71,7 +71,7 @@ pub enum JSGCTraceKind {

pub const JS_DEFAULT_ZEAL_FREQ: u32 = 100;

pub type moz_static_assert6 = [c_int; 1u];
pub type moz_static_assert6 = [c_int; 1];
pub struct JSHandleObject {
pub unnamed_field1: *mut *mut JSObject,
}
@@ -317,14 +317,14 @@ pub struct JSClass {
pub hasInstance: JSHasInstanceOp,
pub construct: JSNative,
pub trace: JSTraceOp,
pub reserved: [*mut c_void; 40u],
pub reserved: [*mut c_void; 40],
}
unsafe impl Sync for JSClass {}
pub struct JSConstDoubleSpec {
pub dval: c_double,
pub name: *const c_char,
pub flags: uint8_t,
pub spare: [uint8_t; 3u],
pub spare: [uint8_t; 3],
}
pub struct JSStrictPropertyOpWrapper {
pub op: JSNative,
@@ -9,7 +9,7 @@ use libc::c_void;
use std::mem;

#[cfg(target_pointer_width = "64")]
const JSVAL_TAG_SHIFT: uint = 47u;
const JSVAL_TAG_SHIFT: u32 = 47;

#[allow(dead_code)]
mod ValueType {
@@ -152,15 +152,15 @@ pub fn UInt32Value(ui: u32) -> JSVal {
#[cfg(target_pointer_width = "64")]
#[inline(always)]
pub fn StringValue(s: &JSString) -> JSVal {
let bits = s as *const JSString as uint as u64;
let bits = s as *const JSString as usize as u64;
assert!((bits >> JSVAL_TAG_SHIFT) == 0);
BuildJSVal(ValueTag::STRING, bits)
}

#[cfg(target_pointer_width = "32")]
#[inline(always)]
pub fn StringValue(s: &JSString) -> JSVal {
let bits = s as *const JSString as uint as u64;
let bits = s as *const JSString as usize as u64;
BuildJSVal(ValueTag::STRING, bits)
}

@@ -172,15 +172,15 @@ pub fn BooleanValue(b: bool) -> JSVal {
#[cfg(target_pointer_width = "64")]
#[inline(always)]
pub fn ObjectValue(o: &JSObject) -> JSVal {
let bits = o as *const JSObject as uint as u64;
let bits = o as *const JSObject as usize as u64;
assert!((bits >> JSVAL_TAG_SHIFT) == 0);
BuildJSVal(ValueTag::OBJECT, bits)
}

#[cfg(target_pointer_width = "32")]
#[inline(always)]
pub fn ObjectValue(o: &JSObject) -> JSVal {
let bits = o as *const JSObject as uint as u64;
let bits = o as *const JSObject as usize as u64;
BuildJSVal(ValueTag::OBJECT, bits)
}

@@ -196,7 +196,7 @@ pub fn ObjectOrNullValue(o: *mut JSObject) -> JSVal {
#[cfg(target_pointer_width = "64")]
#[inline(always)]
pub fn PrivateValue(o: *const c_void) -> JSVal {
let ptrBits = o as uint as u64;
let ptrBits = o as usize as u64;
assert!((ptrBits & 1) == 0);
JSVal {
v: ptrBits >> 1
@@ -206,7 +206,7 @@ pub fn PrivateValue(o: *const c_void) -> JSVal {
#[cfg(target_pointer_width = "32")]
#[inline(always)]
pub fn PrivateValue(o: *const c_void) -> JSVal {
let ptrBits = o as uint as u64;
let ptrBits = o as usize as u64;
assert!((ptrBits & 1) == 0);
BuildJSVal(ValueTag::PRIVATE, ptrBits)
}
@@ -324,7 +324,7 @@ impl JSVal {
assert!(self.is_object_or_null());
let ptrBits = self.v & JSVAL_PAYLOAD_MASK;
assert!((ptrBits & 0x7) == 0);
ptrBits as uint as *mut JSObject
ptrBits as usize as *mut JSObject
}

#[cfg(target_pointer_width = "32")]
@@ -338,7 +338,7 @@ impl JSVal {
pub fn to_private(&self) -> *const c_void {
assert!(self.is_double());
assert!((self.v & 0x8000000000000000u64) == 0);
(self.v << 1) as uint as *const c_void
(self.v << 1) as usize as *const c_void
}

#[cfg(target_pointer_width = "32")]
@@ -5,14 +5,14 @@
#![crate_name = "js"]
#![crate_type = "rlib"]

#![feature(link_args, unsafe_destructor, int_uint)]
#![feature(link_args, unsafe_destructor,collections)]

#![allow(non_upper_case_globals, non_camel_case_types, non_snake_case, improper_ctypes)]

extern crate libc;
#[macro_use]
extern crate log;
extern crate serialize;
extern crate rustc_serialize as serialize;

use libc::c_uint;
use libc::types::common::c99::uint32_t;
@@ -50,7 +50,7 @@ pub const JSOPTION_METHODJIT: uint32_t = (1u32 << 14) as u32;
pub const JSOPTION_TYPE_INFERENCE: uint32_t = (1u32 << 18) as u32;

pub const default_heapsize: u32 = 32_u32 * 1024_u32 * 1024_u32;
pub const default_stacksize: uint = 8192u;
pub const default_stacksize: usize = 8192;
pub const ERR: JSBool = 0_i32;

pub const JSID_TYPE_STRING: i64 = 0;
@@ -74,11 +74,11 @@ pub const JSPROP_NATIVE_ACCESSORS: c_uint = 0x08;

pub const JSCLASS_RESERVED_SLOTS_SHIFT: c_uint = 8;
pub const JSCLASS_RESERVED_SLOTS_WIDTH: c_uint = 8;
pub const JSCLASS_RESERVED_SLOTS_MASK: c_uint = ((1u << JSCLASS_RESERVED_SLOTS_WIDTH as uint) - 1) as c_uint;
pub const JSCLASS_RESERVED_SLOTS_MASK: c_uint = ((1 << JSCLASS_RESERVED_SLOTS_WIDTH) - 1) as c_uint;

pub const JSCLASS_HIGH_FLAGS_SHIFT: c_uint =
JSCLASS_RESERVED_SLOTS_SHIFT + JSCLASS_RESERVED_SLOTS_WIDTH;
pub const JSCLASS_IS_GLOBAL: c_uint = (1<<((JSCLASS_HIGH_FLAGS_SHIFT as uint)+1));
pub const JSCLASS_IS_GLOBAL: c_uint = 1 << (JSCLASS_HIGH_FLAGS_SHIFT + 1);

pub const JSCLASS_GLOBAL_SLOT_COUNT: c_uint = JSProto_LIMIT * 3 + 24;

@@ -98,7 +98,7 @@ pub enum JSGCTraceKind {
}

pub fn JSCLASS_HAS_RESERVED_SLOTS(n: c_uint) -> c_uint {
(n & JSCLASS_RESERVED_SLOTS_MASK) << (JSCLASS_RESERVED_SLOTS_SHIFT as uint)
(n & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT
}

#[inline(always)]
@@ -129,7 +129,7 @@ pub unsafe fn JS_CALLEE(_cx: *mut JSContext, vp: *mut JSVal) -> JSVal {

pub type JSObjectOp = extern "C" fn(*mut JSContext, JSHandleObject) -> *mut JSObject;

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct Class {
pub name: *const libc::c_char,
pub flags: uint32_t,
@@ -151,7 +151,7 @@ pub struct Class {
pub ops: ObjectOps,
}

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ClassExtension {
pub equality: *const u8,
pub outerObject: Option<JSObjectOp>,
@@ -161,7 +161,7 @@ pub struct ClassExtension {
pub isWrappedNative: *const u8,
}

#[derive(Copy)]
#[derive(Copy, Clone)]
pub struct ObjectOps {
pub lookupGeneric: *const u8,
pub lookupProperty: *const u8,
@@ -5,13 +5,10 @@
//! Rust wrappers around the raw JS apis

use libc::types::os::arch::c95::{size_t, c_uint};
use libc::uintptr_t;
use libc::c_char;
use std::cmp;
use std::ffi;
use std::rc;
use std::str;
use std::string;
use std::u32;
use jsapi::*;
use jsapi::JSVersion::JSVERSION_LATEST;
@@ -177,10 +174,10 @@ impl Cx {
}
}

pub fn evaluate_script(&self, glob: *mut JSObject, script: String, filename: String, line_num: uint)
pub fn evaluate_script(&self, glob: *mut JSObject, script: String, filename: String, line_num: usize)
-> Result<(),()> {
let script_utf16: Vec<u16> = script.as_slice().utf16_units().collect();
let filename_cstr = ffi::CString::from_slice(filename.as_bytes());
let script_utf16: Vec<u16> = script.utf16_units().collect();
let filename_cstr = ffi::CString::new(filename.as_bytes()).unwrap();
let mut rval: JSVal = NullValue();
debug!("Evaluating script from {} with content {}", filename, script);
// SpiderMonkey does not approve of null pointers.
@@ -210,14 +207,14 @@ impl Cx {
pub unsafe extern fn reportError(_cx: *mut JSContext, msg: *const c_char, report: *mut JSErrorReport) {
let fnptr = (*report).filename;
let fname = if !fnptr.is_null() {
let c_str = ffi::c_str_to_bytes(&fnptr);
str::from_utf8(c_str).ok().unwrap().to_string()
let c_str = ffi::CStr::from_ptr(fnptr);
str::from_utf8(c_str.to_bytes()).ok().unwrap().to_string()
} else {
"none".to_string()
};
let lineno = (*report).lineno;
let c_str = ffi::c_str_to_bytes(&msg);
let msg = str::from_utf8(c_str).ok().unwrap().to_string();
let c_str = ffi::CStr::from_ptr(msg);
let msg = str::from_utf8(c_str.to_bytes()).ok().unwrap().to_string();
error!("Error at {}:{}: {}\n", fname, lineno, msg);
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.