Permalink
Browse files

Update to Rust 0.6 syntax.

  • Loading branch information...
1 parent 5b246c1 commit 849389c0b0f7ef2111bade1d2bb92d162c851b22 @metajack metajack committed Apr 1, 2013
Showing with 268 additions and 280 deletions.
  1. +6 −6 crust.rs
  2. +5 −5 glue.rs
  3. +82 −96 js.rc
  4. +140 −140 jsapi.rs
  5. +1 −1 jsfriendapi.rs
  6. +3 −3 jsglue.cpp
  7. +16 −16 jsval.rs
  8. +15 −13 rust.rs
View
@@ -1,36 +1,36 @@
use jsapi::*;
-pub extern fn JS_PropertyStub(++cx: *JSContext, ++obj: JSHandleObject, ++id: JSHandleId, ++vp: JSMutableHandleValue) -> JSBool {
+pub extern fn JS_PropertyStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId, vp: JSMutableHandleValue) -> JSBool {
unsafe {
bindgen::JS_PropertyStub(cx, obj, id, vp)
}
}
-pub extern fn JS_StrictPropertyStub(++cx: *JSContext, ++obj: JSHandleObject, ++id: JSHandleId, ++strict: JSBool, ++vp: JSMutableHandleValue) -> JSBool {
+pub extern fn JS_StrictPropertyStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId, strict: JSBool, vp: JSMutableHandleValue) -> JSBool {
unsafe {
bindgen::JS_StrictPropertyStub(cx, obj, id, strict, vp)
}
}
-pub extern fn JS_EnumerateStub(++cx: *JSContext, ++obj: JSHandleObject) -> JSBool {
+pub extern fn JS_EnumerateStub(cx: *JSContext, obj: JSHandleObject) -> JSBool {
unsafe {
bindgen::JS_EnumerateStub(cx, obj)
}
}
-pub extern fn JS_ResolveStub(++cx: *JSContext, ++obj: JSHandleObject, ++id: JSHandleId) -> JSBool {
+pub extern fn JS_ResolveStub(cx: *JSContext, obj: JSHandleObject, id: JSHandleId) -> JSBool {
unsafe {
bindgen::JS_ResolveStub(cx, obj, id)
}
}
-pub extern fn JS_ConvertStub(++cx: *JSContext, ++obj: JSHandleObject, ++_type: JSType, ++vp: JSMutableHandleValue) -> JSBool {
+pub extern fn JS_ConvertStub(cx: *JSContext, obj: JSHandleObject, _type: JSType, vp: JSMutableHandleValue) -> JSBool {
unsafe {
bindgen::JS_ConvertStub(cx, obj, _type, vp)
}
}
-pub extern fn JS_ArrayIterator(++cx: *JSContext, ++argc: libc::c_uint, ++vp: *JSVal) -> JSBool {
+pub extern fn JS_ArrayIterator(cx: *JSContext, argc: libc::c_uint, vp: *JSVal) -> JSBool {
unsafe {
bindgen::JS_ArrayIterator(cx, argc, vp)
}
View
10 glue.rs
@@ -5,11 +5,11 @@ use jsapi::*;
use jsfriendapi::JSJitInfo;
pub type enum_StubType = c_uint;
-pub const PROPERTY_STUB: u32 = 0_u32;
-pub const STRICT_PROPERTY_STUB: u32 = 1_u32;
-pub const ENUMERATE_STUB: u32 = 2_u32;
-pub const CONVERT_STUB: u32 = 3_u32;
-pub const RESOLVE_STUB: u32 = 4_u32;
+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;
pub struct ProxyTraps {
getPropertyDescriptor: *u8,
View
178 js.rc
@@ -4,41 +4,17 @@
extern mod std;
-pub mod jsapi;
-pub mod linkhack;
-pub mod name_pool;
-pub mod rust;
-pub mod global;
-pub mod glue;
-pub mod crust;
-pub mod jsval;
-pub mod jsfriendapi;
-
-use core::ptr::{null, addr_of};
+use core::ptr::null;
use core::result::{Result, Ok, Err};
-use core::libc::{c_char, c_uint};
-use jsapi::{JSBool, JSClass, JSContext, JSErrorReport, JSFunctionSpec,
- JSObject, JSRuntime, JSString, JSVERSION_LATEST, JSVal, jsid,
- JSPropertySpec, JSPropertyOp, JSStrictPropertyOp, JSProto_LIMIT};
-use jsapi::bindgen::{JS_free, JS_AddObjectRoot, JS_DefineFunctions,
- JS_DestroyContext, JS_EncodeString, JS_EvaluateScript,
- JS_Finish, JS_GetContextPrivate, JS_GetPrivate,
- JS_Init, JS_InitStandardClasses,
- JS_NewGlobalObject, JS_NewContext,
- JS_RemoveObjectRoot, JS_SetContextPrivate,
- JS_SetErrorReporter, JS_SetOptions, JS_SetPrivate,
- JS_SetVersion, JS_ValueToString, JS_DefineProperties,
- JS_DefineProperty, JS_NewObject, JS_ComputeThis};
-use core::libc::types::common::c99::{int8_t, int16_t, int32_t, int64_t, uint8_t,
- uint16_t, uint32_t, uint64_t};
+use core::libc::c_uint;
+use jsapi::{JSBool, JSContext,
+ JSObject, JSVal, jsid,
+ JSProto_LIMIT};
+use jsapi::bindgen::JS_ComputeThis;
+use core::libc::types::common::c99::uint32_t;
use jsval::{JSVAL_TO_OBJECT, JSVAL_IS_PRIMITIVE};
use rust::jsobj;
-pub use mod rust;
-
pub use name_pool::NamePool;
-pub use mod jsapi;
-pub use mod glue;
-pub use mod crust;
// These are just macros in jsapi.h
pub use JS_NewRuntime = jsapi::bindgen::JS_Init;
@@ -49,75 +25,87 @@ pub use JS_LockRuntime = jsapi::bindgen::JS_Lock;
pub use JS_UnlockRuntime = jsapi::bindgen::JS_Unlock;
*/
+pub use jsfriendapi::JSJitInfo;
+
+pub mod jsapi;
+pub mod linkhack;
+pub mod name_pool;
+pub mod rust;
+pub mod global;
+pub mod glue;
+pub mod crust;
+pub mod jsval;
+pub mod jsfriendapi;
+
// FIXME: Add the remaining options
-pub const JSOPTION_STRICT: uint32_t = 0b00000000000001u32;
-pub const JSOPTION_WERROR: uint32_t = 0b00000000000010u32;
-pub const JSOPTION_VAROBJFIX: uint32_t = 0b00000000000100u32;
-pub const JSOPTION_METHODJIT: uint32_t = (1 << 14) as u32;
-pub const JSOPTION_TYPE_INFERENCE: uint32_t = (1 << 18) as u32;
-
-pub const default_heapsize: u32 = 8_u32 * 1024_u32 * 1024_u32;
-pub const default_stacksize: uint = 8192u;
-pub const ERR: JSBool = 0_i32;
-
-pub const JSVAL_TAG_MAX_DOUBLE: u64 = 0x1FFF0;
-
-pub const JSVAL_TYPE_DOUBLE: u64 = 0x00;
-pub const JSVAL_TYPE_INT32: u64 = 0x01;
-pub const JSVAL_TYPE_UNDEFINED: u64 = 0x02;
-pub const JSVAL_TYPE_BOOLEAN: u64 = 0x03;
-pub const JSVAL_TYPE_MAGIC: u64 = 0x04;
-pub const JSVAL_TYPE_STRING: u64 = 0x05;
-pub const JSVAL_TYPE_NULL: u64 = 0x06;
-pub const JSVAL_TYPE_OBJECT: u64 = 0x07;
-pub const JSVAL_TYPE_UNKNOWN: u64 = 0x20;
-
-pub const JSVAL_TAG_SHIFT: int = 47;
+pub static JSOPTION_STRICT: uint32_t = 0b00000000000001u32;
+pub static JSOPTION_WERROR: uint32_t = 0b00000000000010u32;
+pub static JSOPTION_VAROBJFIX: uint32_t = 0b00000000000100u32;
+pub static JSOPTION_METHODJIT: uint32_t = (1 << 14) as u32;
+pub static JSOPTION_TYPE_INFERENCE: uint32_t = (1 << 18) as u32;
+
+pub static default_heapsize: u32 = 8_u32 * 1024_u32 * 1024_u32;
+pub static default_stacksize: uint = 8192u;
+pub static ERR: JSBool = 0_i32;
+
+pub static JSVAL_TAG_MAX_DOUBLE: u64 = 0x1FFF0;
+
+pub static JSVAL_TYPE_DOUBLE: u64 = 0x00;
+pub static JSVAL_TYPE_INT32: u64 = 0x01;
+pub static JSVAL_TYPE_UNDEFINED: u64 = 0x02;
+pub static JSVAL_TYPE_BOOLEAN: u64 = 0x03;
+pub static JSVAL_TYPE_MAGIC: u64 = 0x04;
+pub static JSVAL_TYPE_STRING: u64 = 0x05;
+pub static JSVAL_TYPE_NULL: u64 = 0x06;
+pub static JSVAL_TYPE_OBJECT: u64 = 0x07;
+pub static JSVAL_TYPE_UNKNOWN: u64 = 0x20;
+
+pub static JSVAL_TAG_SHIFT: int = 47;
//The following constants are totally broken on non-64bit platforms.
//See jsapi.h for the proper macro definitions.
-pub const JSVAL_VOID: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNKNOWN) << JSVAL_TAG_SHIFT;
-pub const JSVAL_NULL: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) << JSVAL_TAG_SHIFT;
-pub const JSVAL_ZERO: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) << JSVAL_TAG_SHIFT;
-pub const JSVAL_ONE: u64 = ((JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) << JSVAL_TAG_SHIFT) | 1;
-pub const JSVAL_FALSE: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) << JSVAL_TAG_SHIFT;
-pub const JSVAL_TRUE: u64 = ((JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) << JSVAL_TAG_SHIFT) | 1;
-
-pub const JSID_TYPE_STRING: i64 = 0;
-pub const JSID_TYPE_INT: i64 = 1;
-pub const JSID_TYPE_VOID: i64 = 2;
-pub const JSID_TYPE_OBJECT: i64 = 4;
-pub const JSID_TYPE_DEFAULT_XML_NAMESPACE: i64 = 6;
-pub const JSID_TYPE_MASK: i64 = 7;
-
-pub const JSID_VOID: jsid = JSID_TYPE_VOID;
-
-pub const JSFUN_CONSTRUCTOR: u32 = 0x400; /* native that can be called as a ctor */
-
-pub const JSPROP_ENUMERATE: c_uint = 0x01;
-pub const JSPROP_READONLY: c_uint = 0x02;
-pub const JSPROP_PERMANENT: c_uint = 0x04;
-pub const JSPROP_GETTER: c_uint = 0x10;
-pub const JSPROP_SETTER: c_uint = 0x20;
-pub const JSPROP_SHARED: c_uint = 0x40;
-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 = ((1 << JSCLASS_RESERVED_SLOTS_WIDTH) - 1);
-
-pub const JSCLASS_HIGH_FLAGS_SHIFT: c_uint =
+pub static JSVAL_VOID: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNKNOWN) << JSVAL_TAG_SHIFT;
+pub static JSVAL_NULL: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) << JSVAL_TAG_SHIFT;
+pub static JSVAL_ZERO: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) << JSVAL_TAG_SHIFT;
+pub static JSVAL_ONE: u64 = ((JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) << JSVAL_TAG_SHIFT) | 1;
+pub static JSVAL_FALSE: u64 = (JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) << JSVAL_TAG_SHIFT;
+pub static JSVAL_TRUE: u64 = ((JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) << JSVAL_TAG_SHIFT) | 1;
+
+pub static JSID_TYPE_STRING: i64 = 0;
+pub static JSID_TYPE_INT: i64 = 1;
+pub static JSID_TYPE_VOID: i64 = 2;
+pub static JSID_TYPE_OBJECT: i64 = 4;
+pub static JSID_TYPE_DEFAULT_XML_NAMESPACE: i64 = 6;
+pub static JSID_TYPE_MASK: i64 = 7;
+
+pub static JSID_VOID: jsid = JSID_TYPE_VOID;
+
+pub static JSFUN_CONSTRUCTOR: u32 = 0x400; /* native that can be called as a ctor */
+
+pub static JSPROP_ENUMERATE: c_uint = 0x01;
+pub static JSPROP_READONLY: c_uint = 0x02;
+pub static JSPROP_PERMANENT: c_uint = 0x04;
+pub static JSPROP_GETTER: c_uint = 0x10;
+pub static JSPROP_SETTER: c_uint = 0x20;
+pub static JSPROP_SHARED: c_uint = 0x40;
+pub static JSPROP_NATIVE_ACCESSORS: c_uint = 0x08;
+
+pub static JSCLASS_RESERVED_SLOTS_SHIFT: c_uint = 8;
+pub static JSCLASS_RESERVED_SLOTS_WIDTH: c_uint = 8;
+pub static JSCLASS_RESERVED_SLOTS_MASK: c_uint = ((1 << JSCLASS_RESERVED_SLOTS_WIDTH) - 1);
+
+pub static 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+1));
+pub static JSCLASS_IS_GLOBAL: c_uint = (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1));
-pub const JSCLASS_GLOBAL_SLOT_COUNT: c_uint = JSProto_LIMIT * 3 + 24;
+pub static JSCLASS_GLOBAL_SLOT_COUNT: c_uint = JSProto_LIMIT * 3 + 24;
-pub const JSCLASS_IS_DOMJSCLASS: u32 = 1 << 4;
-pub const JSCLASS_USERBIT1: u32 = 1 << 7;
+pub static JSCLASS_IS_DOMJSCLASS: u32 = 1 << 4;
+pub static JSCLASS_USERBIT1: u32 = 1 << 7;
-pub const JSSLOT_PROXY_PRIVATE: u32 = 1;
+pub static JSSLOT_PROXY_PRIVATE: u32 = 1;
-pub pure fn JSCLASS_HAS_RESERVED_SLOTS(n: c_uint) -> c_uint {
+pub fn JSCLASS_HAS_RESERVED_SLOTS(n: c_uint) -> c_uint {
(n & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT
}
@@ -156,8 +144,6 @@ pub unsafe fn JS_CALLEE(_cx: *JSContext, vp: *JSVal) -> *JSVal {
vp
}
-pub use jsfriendapi::JSJitInfo;
-
// This is a duplication of the shadow stuff from jsfriendapi.h. Here
// there be dragons!
mod shadow {
@@ -177,7 +163,7 @@ mod shadow {
_1: jsid,
slotInfo: u32
}
- const FIXED_SLOTS_SHIFT: u32 = 27;
+ static FIXED_SLOTS_SHIFT: u32 = 27;
pub struct Object {
shape: *Shape,
@@ -188,7 +174,7 @@ mod shadow {
pub impl Object {
#[inline(always)]
- pure fn numFixedSlots(&self) -> libc::size_t {
+ fn numFixedSlots(&self) -> libc::size_t {
unsafe { ((*self.shape).slotInfo >> FIXED_SLOTS_SHIFT) as libc::size_t }
}
@@ -199,7 +185,7 @@ mod shadow {
// Like slotRef, but just returns the value, not a reference
#[inline(always)]
- pure fn slotVal(&self, slot: libc::size_t) -> JSVal {
+ fn slotVal(&self, slot: libc::size_t) -> JSVal {
unsafe {
let nfixed : libc::size_t = self.numFixedSlots();
if slot < nfixed {
Oops, something went wrong.

0 comments on commit 849389c

Please sign in to comment.