Permalink
Browse files

Update for newest Rust

  • Loading branch information...
1 parent 6341d7a commit 479fb5152a64e81e649650df63d99f3b986d3329 @pcwalton pcwalton committed Oct 19, 2012
Showing with 175 additions and 174 deletions.
  1. +6 −6 global.rs
  2. +23 −23 glue.rs
  3. +12 −12 js.rs
  4. +105 −105 jsapi.rs
  5. +5 −5 jsval.rs
  6. +4 −4 name_pool.rs
  7. +20 −19 rust.rs
View
@@ -9,8 +9,8 @@ use glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB,
RESOLVE_STUB, CONVERT_STUB};
use libc::c_uint;
-pub fn basic_class(np: name_pool, -name: ~str) -> JSClass {
- {name: np.add(name),
+pub fn basic_class(np: NamePool, -name: ~str) -> JSClass {
+ {name: np.add(move name),
flags: JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT),
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
@@ -35,18 +35,18 @@ pub fn basic_class(np: name_pool, -name: ~str) -> JSClass {
null(), null(), null(), null(), null())} // 40
}
-pub fn global_class(np: name_pool) -> JSClass {
+pub fn global_class(np: NamePool) -> JSClass {
basic_class(np, ~"global")
}
pub unsafe fn jsval_to_rust_str(cx: *JSContext, vp: *jsapi::JSString) -> ~str {
let bytes = JS_EncodeString(cx, vp);
let s = str::raw::from_c_str(bytes);
JS_free(cx, cast::reinterpret_cast(&bytes));
- s
+ move s
}
-pub extern fn debug(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
+pub extern fn debug(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
use io::WriterUtil;
unsafe {
@@ -60,7 +60,7 @@ pub extern fn debug(cx: *JSContext, argc: c_uint, vp: *jsval) -> JSBool {
}
}
-pub fn debug_fns(np: name_pool) -> ~[JSFunctionSpec] {
+pub fn debug_fns(np: NamePool) -> ~[JSFunctionSpec] {
~[{name: np.add(~"debug"),
call: {op: debug,
info: null()},
View
46 glue.rs
@@ -16,72 +16,72 @@ pub extern mod bindgen {
pub fn GetJSClassHookStubPointer(++_type: enum_StubType) -> *c_void;
#[rust_stack]
-pub fn RUST_JSVAL_IS_NULL(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_NULL(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_IS_VOID(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_VOID(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_IS_INT(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_INT(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_TO_INT(++v: jsval) -> int32_t;
+pub fn RUST_JSVAL_TO_INT(++v: JSVal) -> int32_t;
#[rust_stack]
-pub fn RUST_INT_TO_JSVAL(++v: int32_t) -> jsval;
+pub fn RUST_INT_TO_JSVAL(++v: int32_t) -> JSVal;
#[rust_stack]
-pub fn RUST_JSVAL_IS_DOUBLE(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_DOUBLE(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_TO_DOUBLE(++v: jsval) -> c_double;
+pub fn RUST_JSVAL_TO_DOUBLE(++v: JSVal) -> c_double;
#[rust_stack]
-pub fn RUST_DOUBLE_TO_JSVAL(++v: c_double) -> jsval;
+pub fn RUST_DOUBLE_TO_JSVAL(++v: c_double) -> JSVal;
#[rust_stack]
-pub fn RUST_UINT_TO_JSVAL(++v: uint32_t) -> jsval;
+pub fn RUST_UINT_TO_JSVAL(++v: uint32_t) -> JSVal;
#[rust_stack]
-pub fn RUST_JSVAL_IS_NUMBER(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_NUMBER(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_IS_STRING(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_STRING(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_TO_STRING(++v: jsval) -> *JSString;
+pub fn RUST_JSVAL_TO_STRING(++v: JSVal) -> *JSString;
#[rust_stack]
-pub fn RUST_STRING_TO_JSVAL(++v: *JSString) -> jsval;
+pub fn RUST_STRING_TO_JSVAL(++v: *JSString) -> JSVal;
#[rust_stack]
-pub fn RUST_JSVAL_TO_OBJECT(++v: jsval) -> *JSObject;
+pub fn RUST_JSVAL_TO_OBJECT(++v: JSVal) -> *JSObject;
#[rust_stack]
-pub fn RUST_OBJECT_TO_JSVAL(++v: *JSObject) -> jsval;
+pub fn RUST_OBJECT_TO_JSVAL(++v: *JSObject) -> JSVal;
#[rust_stack]
-pub fn RUST_JSVAL_IS_BOOLEAN(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_BOOLEAN(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_TO_BOOLEAN(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_TO_BOOLEAN(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_BOOLEAN_TO_JSVAL(++v: JSBool) -> jsval;
+pub fn RUST_BOOLEAN_TO_JSVAL(++v: JSBool) -> JSVal;
#[rust_stack]
-pub fn RUST_JSVAL_IS_PRIMITIVE(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_PRIMITIVE(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_IS_GCTHING(++v: jsval) -> JSBool;
+pub fn RUST_JSVAL_IS_GCTHING(++v: JSVal) -> JSBool;
#[rust_stack]
-pub fn RUST_JSVAL_TO_GCTHING(++v: jsval) -> *c_void;
+pub fn RUST_JSVAL_TO_GCTHING(++v: JSVal) -> *c_void;
#[rust_stack]
-pub fn RUST_PRIVATE_TO_JSVAL(++v: *c_void) -> jsval;
+pub fn RUST_PRIVATE_TO_JSVAL(++v: *c_void) -> JSVal;
#[rust_stack]
-pub fn RUST_JSVAL_TO_PRIVATE(++v: jsval) -> *c_void;
+pub fn RUST_JSVAL_TO_PRIVATE(++v: JSVal) -> *c_void;
}
View
24 js.rs
@@ -1,11 +1,11 @@
use ptr::{null, addr_of};
use result::{Result, Ok, Err};
use libc::{c_char, c_uint};
-use name_pool::{name_pool, add};
+use name_pool::{NamePool, add};
use str::raw::from_c_str;
use io::WriterUtil;
use jsapi::{JSBool, JSClass, JSContext, JSErrorReport, JSFunctionSpec,
- JSObject, JSRuntime, JSString, JSVERSION_LATEST, jsval, jsid,
+ 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,
@@ -23,7 +23,7 @@ use glue::bindgen::{RUST_JSVAL_TO_OBJECT, RUST_JSVAL_IS_PRIMITIVE};
use rust::jsobj;
pub use rust;
-pub use name_pool;
+pub use NamePool;
pub use mod jsapi;
pub use mod glue;
pub use mod crust;
@@ -103,17 +103,17 @@ pub type named_functions = @{
};
#[inline(always)]
-pub unsafe fn JS_ARGV(_cx: *JSContext, vp: *jsval) -> *jsval {
+pub unsafe fn JS_ARGV(_cx: *JSContext, vp: *JSVal) -> *JSVal {
ptr::offset(vp, 2u)
}
-pub unsafe fn JS_SET_RVAL(_cx: *JSContext, vp: *jsval, v: jsval) {
- let vp: *mut jsval = cast::reinterpret_cast(&vp);
+pub unsafe fn JS_SET_RVAL(_cx: *JSContext, vp: *JSVal, v: JSVal) {
+ let vp: *mut JSVal = cast::reinterpret_cast(&vp);
*vp = v;
}
#[inline(always)]
-pub unsafe fn JS_THIS_OBJECT(cx: *JSContext, vp: *jsval) -> *JSObject unsafe {
+pub unsafe fn JS_THIS_OBJECT(cx: *JSContext, vp: *JSVal) -> *JSObject unsafe {
let r = JSVAL_TO_OBJECT(
if JSVAL_IS_PRIMITIVE(*ptr::offset(vp, 1)) {
JS_ComputeThis(cx, vp)
@@ -145,8 +145,8 @@ mod shadow {
pub struct Object {
shape: *Shape,
objType: *TypeObject,
- slots: *jsval,
- _1: *jsval,
+ slots: *JSVal,
+ _1: *JSVal,
}
impl Object {
@@ -157,12 +157,12 @@ mod shadow {
#[inline(always)]
fn fixedSlots() -> *jsval {
- (ptr::offset(ptr::to_unsafe_ptr(&self), 1)) as *jsval
+ (ptr::offset(ptr::to_unsafe_ptr(&self), 1)) as *JSVal
}
// Like slotRef, but just returns the value, not a reference
#[inline(always)]
- pure fn slotVal(slot: libc::size_t) -> jsval unsafe {
+ pure fn slotVal(slot: libc::size_t) -> JSVal unsafe {
let nfixed : libc::size_t = self.numFixedSlots();
if slot < nfixed {
return *ptr::offset(self.fixedSlots(), slot as uint)
@@ -173,7 +173,7 @@ mod shadow {
}
#[inline(always)]
-pub unsafe fn GetReservedSlot(obj: *JSObject, slot: libc::size_t) -> jsval {
+pub unsafe fn GetReservedSlot(obj: *JSObject, slot: libc::size_t) -> JSVal {
let s = obj as *shadow::Object;
return (*s).slotVal(slot)
}
Oops, something went wrong.

0 comments on commit 479fb51

Please sign in to comment.