From b731832de6c591674e2a17befe91281d44f52d29 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 16 Sep 2014 11:40:07 -0700 Subject: [PATCH 1/2] Rust upgrade --- src/lib.rs | 8 ++++---- src/rust.rs | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bdeabf400..66ae05275 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,12 +26,12 @@ use jsapi::JS_ComputeThis; use jsval::JSVal; // These are just macros in jsapi.h -pub use JS_NewRuntime = jsapi::JS_Init; -pub use JS_DestroyRuntime = jsapi::JS_Finish; +pub use jsapi::JS_Init as JS_NewRuntime; +pub use jsapi::JS_Finish as JS_DestroyRuntime; /* FIXME: Not sure where JS_Lock is -pub use JS_LockRuntime = jsapi::bindgen::JS_Lock; -pub use JS_UnlockRuntime = jsapi::bindgen::JS_Unlock; +pub use jsapi::bindgen::JS_Lock as JS_LockRuntime; +pub use jsapi::bindgen::JS_Unlock as JS_UnlockRuntime; */ pub use jsfriendapi::JSJitInfo; diff --git a/src/rust.rs b/src/rust.rs index 1f23807f6..556a8d853 100644 --- a/src/rust.rs +++ b/src/rust.rs @@ -5,6 +5,7 @@ //! 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::rc; @@ -56,14 +57,15 @@ impl RtUtils for rc::Rc { } } -extern fn gc_callback(rt: *mut JSRuntime, _status: JSGCStatus) { +unsafe extern fn gc_callback(rt: *mut JSRuntime, _status: JSGCStatus) { use std::rt::local::Local; use std::rt::task::Task; unsafe { let mut task = Local::borrow(None::); let green_task: Box = task.maybe_take_runtime().unwrap(); let (start, end) = green_task.stack_bounds(); - JS_SetNativeStackBounds(rt, cmp::min(start, end), cmp::max(start, end)); + JS_SetNativeStackBounds(rt, cmp::min(start, end) as uintptr_t, + cmp::max(start, end) as uintptr_t); task.put_runtime(green_task); } } @@ -161,14 +163,12 @@ impl Cx { } } -pub extern fn reportError(_cx: *mut JSContext, msg: *const c_char, report: *mut JSErrorReport) { - unsafe { - let fnptr = (*report).filename; - let fname = if fnptr.is_not_null() {string::raw::from_buf(fnptr as *const i8 as *const u8)} else {"none".to_string()}; - let lineno = (*report).lineno; - let msg = string::raw::from_buf(msg as *const i8 as *const u8); - error!("Error at {:s}:{}: {:s}\n", fname, lineno, msg); - } +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() {string::raw::from_buf(fnptr as *const i8 as *const u8)} else {"none".to_string()}; + let lineno = (*report).lineno; + let msg = string::raw::from_buf(msg as *const i8 as *const u8); + error!("Error at {:s}:{}: {:s}\n", fname, lineno, msg); } pub fn with_compartment(cx: *mut JSContext, object: *mut JSObject, cb: || -> R) -> R { From c151eb31d0c6c96b5fe1819ff23bfab935a543e9 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Tue, 16 Sep 2014 16:25:46 -0700 Subject: [PATCH 2/2] Store unsafe fns in ProxyTraps fields --- src/glue.rs | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/glue.rs b/src/glue.rs index 81ccd30f3..8decabc1d 100644 --- a/src/glue.rs +++ b/src/glue.rs @@ -12,35 +12,35 @@ use jsval::JSVal; pub static JS_STRUCTURED_CLONE_VERSION: u32 = 1; pub struct ProxyTraps { - pub getPropertyDescriptor: Option bool>, - pub getOwnPropertyDescriptor: Option bool>, - pub defineProperty: Option bool>, + pub getPropertyDescriptor: Option bool>, + pub getOwnPropertyDescriptor: Option bool>, + pub defineProperty: Option bool>, pub getOwnPropertyNames: *const u8, //XXX need a representation for AutoIdVector& - pub delete_: Option bool>, + pub delete_: Option bool>, pub enumerate: *const u8, //XXX need a representation for AutoIdVector& - pub has: Option bool>, - pub hasOwn: Option bool>, - pub get: Option bool>, - pub set: Option bool>, + pub has: Option bool>, + pub hasOwn: Option bool>, + pub get: Option bool>, + pub set: Option bool>, pub keys: *const u8, //XXX need a representation for AutoIdVector& - pub iterate: Option bool>, + pub iterate: Option bool>, - pub call: Option bool>, - pub construct: Option bool>, + pub call: Option bool>, + pub construct: Option bool>, pub nativeCall: *const u8, //XXX need a representation for IsAcceptableThis, NativeImpl, and CallArgs - pub hasInstance: Option bool>, - pub typeOf: Option uint>, //XXX JSType enum - pub objectClassIs: Option bool>, //XXX ESClassValue enum - pub obj_toString: Option *mut JSString>, - pub fun_toString: Option *mut JSString>, + pub hasInstance: Option bool>, + pub typeOf: Option uint>, //XXX JSType enum + pub objectClassIs: Option bool>, //XXX ESClassValue enum + pub obj_toString: Option *mut JSString>, + pub fun_toString: Option *mut JSString>, //regexp_toShared: *u8, - pub defaultValue: Option bool>, //XXX JSType enum - pub iteratorNext: Option bool>, - pub finalize: Option, - pub getElementIfPresent: Option bool>, - pub getPrototypeOf: Option bool>, - pub trace: Option, + pub defaultValue: Option bool>, //XXX JSType enum + pub iteratorNext: Option bool>, + pub finalize: Option, + pub getElementIfPresent: Option bool>, + pub getPrototypeOf: Option bool>, + pub trace: Option, } #[link(name = "jsglue")]