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

Rustup 20150109 #132

Merged
merged 3 commits into from Jan 28, 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

Fix fn coercions, deriving -> derive, is_not_null, etc.

  • Loading branch information
jdm committed Jan 16, 2015
commit 59a562a6d52d6dce37dfdc4536d0762b58904e49
@@ -82,7 +82,7 @@ const JSVAL_PAYLOAD_MASK: u64 = 0x00007FFFFFFFFFFF;

// JSVal was originally type of u64.
// now this become {u64} because of the union abi issue on ARM arch. See #398.
#[deriving(PartialEq, Clone, Copy)]
#[derive(PartialEq, Clone, Copy)]
pub struct JSVal {
pub v: u64
}
@@ -110,13 +110,14 @@ pub unsafe fn JS_SET_RVAL(_cx: *mut JSContext, vp: *mut JSVal, v: JSVal) {
*vp = v;
}

#[inline(alwyas)]
#[inline(always)]
pub unsafe fn JS_THIS_OBJECT(cx: *mut JSContext, vp: *mut JSVal) -> *mut JSObject {
let val = *vp.offset(1);
let r =
if (*(vp.offset(1))).is_primitive() {
if val.is_primitive() {
JS_ComputeThis(cx, vp)
} else {
*(vp.offset(1))
val
};
r.to_object_or_null()
}
@@ -128,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;

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

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

#[deriving(Copy)]
#[derive(Copy)]
pub struct ObjectOps {
pub lookupGeneric: *const u8,
pub lookupProperty: *const u8,
@@ -54,7 +54,7 @@ pub trait RtUtils {
impl RtUtils for rc::Rc<rt_rsrc> {
fn cx(&self) -> rc::Rc<Cx> {
unsafe {
new_context(JS_NewContext(self.deref().ptr,
new_context(JS_NewContext(self.ptr,
default_stacksize as size_t), self.clone())
}
}
@@ -114,7 +114,7 @@ impl Cx {

pub fn set_logging_error_reporter(&self) {
unsafe {
JS_SetErrorReporter(self.ptr, Some(reportError));
JS_SetErrorReporter(self.ptr, Some(reportError as unsafe extern "C" fn(*mut JSContext, *const c_char, *mut JSErrorReport)));
}
}

@@ -127,7 +127,7 @@ impl Cx {
pub fn evaluate_script(&self, glob: *mut JSObject, script: String, filename: String, line_num: uint)
-> Result<(),()> {
let script_utf16: Vec<u16> = script.as_slice().utf16_units().collect();
let filename_cstr = filename.to_c_str();
let filename_cstr = ffi::CString::from_slice(filename.as_bytes());
let mut rval: JSVal = NullValue();
debug!("Evaluating script from {} with content {}", filename, script);
// SpiderMonkey does not approve of null pointers.
@@ -137,7 +137,7 @@ impl Cx {
} else {
(script_utf16.as_ptr(), script_utf16.len() as c_uint)
};
assert!(ptr.is_not_null());
assert!(!ptr.is_null());
unsafe {
if ERR == JS_EvaluateUCScript(self.ptr, glob, ptr, len,
filename_cstr.as_ptr(), line_num as c_uint,
@@ -156,7 +156,7 @@ 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_not_null() {
let fname = if !fnptr.is_null() {
let c_str = ffi::c_str_to_bytes(&fnptr);
str::from_utf8(c_str).ok().unwrap().to_string()
} else {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.