diff --git a/crust.rs b/crust.rs deleted file mode 100644 index 65be9156c..000000000 --- a/crust.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use std::libc; -use jsapi; -use jsapi::*; -use jsval::JSVal; - -pub extern fn JS_PropertyStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId, vp: JSMutableHandleValue) -> JSBool { - unsafe { - jsapi::JS_PropertyStub(cx, obj, id, vp) - } -} - -pub extern fn JS_StrictPropertyStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId, strict: JSBool, vp: JSMutableHandleValue) -> JSBool { - unsafe { - jsapi::JS_StrictPropertyStub(cx, obj, id, strict, vp) - } -} - -pub extern fn JS_EnumerateStub(cx: *JSContext, obj: JSHandleObject) -> JSBool { - unsafe { - jsapi::JS_EnumerateStub(cx, obj) - } -} - -pub extern fn JS_ResolveStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId) -> JSBool { - unsafe { - jsapi::JS_ResolveStub(cx, obj, id) - } -} - -pub extern fn JS_ConvertStub(cx: *JSContext, obj: JSHandleObject, _type: JSType, vp: JSMutableHandleValue) -> JSBool { - unsafe { - jsapi::JS_ConvertStub(cx, obj, _type, vp) - } -} - -pub extern fn JS_ArrayIterator(cx: *JSContext, argc: libc::c_uint, vp: *mut JSVal) -> JSBool { - unsafe { - jsapi::JS_ArrayIterator(cx, argc, &*vp) - } -} - diff --git a/global.rs b/global.rs index b41a5f4ec..4d97a99f5 100644 --- a/global.rs +++ b/global.rs @@ -8,18 +8,15 @@ Handy functions for creating class objects and so forth. "]; -use crust; -use glue::GetJSClassHookStubPointer; -use glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, - RESOLVE_STUB, CONVERT_STUB}; use std::libc::{c_uint, c_void}; use std::str::raw::from_c_str; use std::cast::transmute; use std::ptr::null; use jsapi; -use jsapi::{JSClass, JSContext, JSFunctionSpec, JSBool, JSNativeWrapper}; -use jsapi::{JS_EncodeString, JS_free, JS_ValueToBoolean, JS_ValueToString}; -use jsapi::{JS_ReportError, JS_ValueToSource, JS_GC, JS_GetRuntime}; +use jsapi::{JSClass, JSContext, JSFunctionSpec, JSBool, JSNativeWrapper, JS_EnumerateStub}; +use jsapi::{JS_EncodeString, JS_free, JS_ValueToBoolean, JS_ValueToString, JS_ConvertStub}; +use jsapi::{JS_ReportError, JS_ValueToSource, JS_GC, JS_GetRuntime, JS_PropertyStub}; +use jsapi::{JS_StrictPropertyStub, JS_ResolveStub}; use jsfriendapi::JSJitInfo; use jsval::{JSVal, UndefinedValue}; use JSCLASS_IS_GLOBAL; @@ -34,13 +31,13 @@ static global_name: [i8, ..7] = ['g' as i8, 'l' as i8, 'o' as i8, 'b' as i8, 'a' pub static BASIC_GLOBAL: JSClass = JSClass { name: &global_name as *i8, flags: JSCLASS_IS_GLOBAL | (((JSCLASS_GLOBAL_SLOT_COUNT + 1) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT), - addProperty: Some(crust::JS_PropertyStub), - delProperty: Some(crust::JS_PropertyStub), - getProperty: Some(crust::JS_PropertyStub), - setProperty: Some(crust::JS_StrictPropertyStub), - enumerate: Some(crust::JS_EnumerateStub), - resolve: Some(crust::JS_ResolveStub), - convert: Some(crust::JS_ConvertStub), + addProperty: Some(JS_PropertyStub), + delProperty: Some(JS_PropertyStub), + getProperty: Some(JS_PropertyStub), + setProperty: Some(JS_StrictPropertyStub), + enumerate: Some(JS_EnumerateStub), + resolve: Some(JS_ResolveStub), + convert: Some(JS_ConvertStub), finalize: None, checkAccess: None, call: None, @@ -61,13 +58,13 @@ pub fn basic_class(name: &'static str) -> JSClass { JSClass { name: name.as_ptr() as *i8, flags: JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + 1), - addProperty: unsafe { Some(transmute(GetJSClassHookStubPointer(PROPERTY_STUB))) }, - delProperty: unsafe { Some(transmute(GetJSClassHookStubPointer(PROPERTY_STUB))) }, - getProperty: unsafe { Some(transmute(GetJSClassHookStubPointer(PROPERTY_STUB))) }, - setProperty: unsafe { Some(transmute(GetJSClassHookStubPointer(STRICT_PROPERTY_STUB))) }, - enumerate: unsafe { Some(transmute(GetJSClassHookStubPointer(ENUMERATE_STUB))) }, - resolve: unsafe { Some(transmute(GetJSClassHookStubPointer(RESOLVE_STUB))) }, - convert: unsafe { Some(transmute(GetJSClassHookStubPointer(CONVERT_STUB))) }, + addProperty: Some(JS_PropertyStub), + delProperty: Some(JS_PropertyStub), + getProperty: Some(JS_PropertyStub), + setProperty: Some(JS_StrictPropertyStub), + enumerate: Some(JS_EnumerateStub), + resolve: Some(JS_ResolveStub), + convert: Some(JS_ConvertStub), finalize: None, checkAccess: None, call: None, diff --git a/glue.rs b/glue.rs index f8d9119ae..aa6709ada 100644 --- a/glue.rs +++ b/glue.rs @@ -10,13 +10,6 @@ use jsapi::*; use jsfriendapi::JSJitInfo; use jsval::JSVal; -pub type enum_StubType = c_uint; -pub static PROPERTY_STUB: u32 = 0_u32; -pub static STRICT_PROPERTY_STUB: u32 = 1_u32; -pub static ENUMERATE_STUB: u32 = 2_u32; -pub static CONVERT_STUB: u32 = 3_u32; -pub static RESOLVE_STUB: u32 = 4_u32; - type c_bool = libc::c_int; pub struct ProxyTraps { @@ -62,10 +55,6 @@ extern { } extern { -// FIXME: Couldn't run on rust_stack until rust issue #6470 fixed. -//#[rust_stack] -pub fn GetJSClassHookStubPointer(_type: enum_StubType) -> *c_void; - //#[rust_stack] pub fn RUST_JS_NumberValue(d: f64) -> JSVal; diff --git a/js.rc b/js.rc index 62cd641a3..e1dd53d9d 100644 --- a/js.rc +++ b/js.rc @@ -49,7 +49,6 @@ pub mod rust; pub mod global; pub mod glue; pub mod trace; -pub mod crust; pub mod jsval; pub mod jsfriendapi; diff --git a/jsapi.rs b/jsapi.rs index c2e88c5e1..f2bc8510f 100644 --- a/jsapi.rs +++ b/jsapi.rs @@ -281,19 +281,19 @@ pub struct JSMutableHandleValue { pub type JSRawObject = *JSObject; -pub type JSPropertyOp = extern "C" fn(*JSContext, JSHandleObject, JSHandleId, JSMutableHandleValue) -> JSBool; +pub type JSPropertyOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSHandleId, JSMutableHandleValue) -> JSBool; -pub type JSStrictPropertyOp = extern "C" fn(*JSContext, JSHandleObject, JSHandleId, JSBool, JSMutableHandleValue) -> JSBool; +pub type JSStrictPropertyOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSHandleId, JSBool, JSMutableHandleValue) -> JSBool; pub type JSNewEnumerateOp = *u8; -pub type JSEnumerateOp = extern "C" fn(*JSContext, JSHandleObject) -> JSBool; +pub type JSEnumerateOp = extern "C" unsafe fn(*JSContext, JSHandleObject) -> JSBool; -pub type JSResolveOp = extern "C" fn(*JSContext, JSHandleObject, JSHandleId) -> JSBool; +pub type JSResolveOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSHandleId) -> JSBool; pub type JSNewResolveOp = *u8; -pub type JSConvertOp = extern "C" fn(*JSContext, JSHandleObject, JSType, JSMutableHandleValue) -> JSBool; +pub type JSConvertOp = extern "C" unsafe fn(*JSContext, JSHandleObject, JSType, JSMutableHandleValue) -> JSBool; pub type JSTypeOfOp = *u8; @@ -322,7 +322,7 @@ pub type JSTraceNamePrinter = *u8; pub type JSEqualityOp = *u8; -pub type JSNative = extern "C" fn(*JSContext, c_uint, *mut JSVal) -> JSBool; +pub type JSNative = extern "C" unsafe fn(*JSContext, c_uint, *mut JSVal) -> JSBool; pub type enum_JSContextOp = c_uint; pub static JSCONTEXT_NEW: u32 = 0_u32; @@ -1156,7 +1156,7 @@ pub fn JS_NewPropertyIterator(cx: *JSContext, obj: *JSObject) -> *JSObject; pub fn JS_NextProperty(cx: *JSContext, iterobj: *JSObject, idp: *jsid) -> JSBool; -pub fn JS_ArrayIterator(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool; +pub fn JS_ArrayIterator(cx: *JSContext, argc: c_uint, vp: *mut JSVal) -> JSBool; pub fn JS_CheckAccess(cx: *JSContext, obj: *JSObject, id: jsid, mode: JSAccessMode, vp: *JSVal, attrsp: *c_uint) -> JSBool; diff --git a/jsglue.cpp b/jsglue.cpp index 085e1273c..79a8d61e6 100644 --- a/jsglue.cpp +++ b/jsglue.cpp @@ -12,14 +12,6 @@ #include "assert.h" -enum StubType { - PROPERTY_STUB, - STRICT_PROPERTY_STUB, - ENUMERATE_STUB, - CONVERT_STUB, - RESOLVE_STUB, -}; - struct ProxyTraps { bool (*getPropertyDescriptor)(JSContext *cx, JSObject *proxy, jsid id, bool set, JSPropertyDescriptor *desc); @@ -280,24 +272,6 @@ InvokeGetOwnPropertyDescriptor( desc); } -void* -GetJSClassHookStubPointer(enum StubType type) -{ - switch (type) { - case PROPERTY_STUB: - return (void*)JS_PropertyStub; - case STRICT_PROPERTY_STUB: - return (void*)JS_StrictPropertyStub; - case ENUMERATE_STUB: - return (void*)JS_EnumerateStub; - case CONVERT_STUB: - return (void*)JS_ConvertStub; - case RESOLVE_STUB: - return (void*)JS_ResolveStub; - } - return NULL; -} - jsval RUST_JS_NumberValue(double d) {