Use *mut T for the T* pointers in SpiderMonkey.

This commit is contained in:
Ms2ger 2014-05-26 18:19:44 +02:00
parent 3e4b2c1c7b
commit d5cb4377ef
18 changed files with 294 additions and 308 deletions

View file

@ -4,7 +4,7 @@
use js::jsapi::{JSContext, JSBool};
use js::jsapi::{JS_IsExceptionPending};
use js::jsapi::{JS_ReportErrorNumber, JSErrorFormatString, struct_JSErrorFormatString, JSEXN_TYPEERR};
use js::jsapi::{JS_ReportErrorNumber, JSErrorFormatString, JSEXN_TYPEERR};
use js::glue::{ReportError};
use libc;
@ -29,7 +29,7 @@ pub type Fallible<T> = Result<T, Error>;
pub type ErrorResult = Fallible<()>;
pub fn throw_method_failed_with_details<T>(cx: *JSContext,
pub fn throw_method_failed_with_details<T>(cx: *mut JSContext,
result: Result<T, Error>,
interface: &'static str,
member: &'static str) -> JSBool {
@ -42,7 +42,7 @@ pub fn throw_method_failed_with_details<T>(cx: *JSContext,
return 0;
}
pub fn throw_not_in_union(cx: *JSContext, names: &'static str) -> JSBool {
pub fn throw_not_in_union(cx: *mut JSContext, names: &'static str) -> JSBool {
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
let message = format!("argument could not be converted to any of: {}", names);
message.with_c_str(|string| {
@ -58,7 +58,7 @@ static ERROR_FORMAT_STRING_STRING: [libc::c_char, ..4] = [
0 as libc::c_char,
];
static ERROR_FORMAT_STRING: JSErrorFormatString = struct_JSErrorFormatString {
static ERROR_FORMAT_STRING: JSErrorFormatString = JSErrorFormatString {
format: &ERROR_FORMAT_STRING_STRING as *libc::c_char,
argCount: 1,
exnType: JSEXN_TYPEERR as i16,
@ -72,9 +72,9 @@ extern fn get_error_message(_user_ref: *mut libc::c_void,
&ERROR_FORMAT_STRING as *JSErrorFormatString
}
pub fn throw_type_error(cx: *JSContext, error: &str) {
pub fn throw_type_error(cx: *mut JSContext, error: &str) {
let error = error.to_c_str();
error.with_ref(|error| unsafe {
JS_ReportErrorNumber(cx, get_error_message, ptr::null(), 0, error);
JS_ReportErrorNumber(cx, Some(get_error_message), ptr::mut_null(), 0, error);
});
}