Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Language changes.

  • Loading branch information...
commit f796ad48dae00987ab6bc0c64031ecb8358a9c08 1 parent fa9a1e3
@jdm jdm authored
View
2  crust.rs
@@ -30,7 +30,7 @@ pub extern fn JS_ConvertStub(++cx: *JSContext, ++obj: JSHandleObject, ++_type: J
}
}
-pub extern fn JS_ArrayIterator(++cx: *JSContext, ++argc: 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
12 global.rs
@@ -7,9 +7,11 @@ Handy functions for creating class objects and so forth.
use glue::bindgen::GetJSClassHookStubPointer;
use glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB,
RESOLVE_STUB, CONVERT_STUB};
-use libc::c_uint;
+use core::libc::c_uint;
+use core::str::raw::from_c_str;
+use core::cast::reinterpret_cast;
use name_pool::*;
-use ptr::null;
+use core::ptr::null;
use jsapi;
use jsapi::{JSClass, JSContext, JSVal, JSFunctionSpec, JSBool, JSNativeWrapper};
use jsapi::bindgen::{JS_EncodeString, JS_free, JS_ValueToString};
@@ -57,14 +59,14 @@ pub unsafe fn jsval_to_rust_str(cx: *JSContext, vp: *jsapi::JSString) -> ~str {
~""
} else {
let bytes = JS_EncodeString(cx, vp);
- let s = str::raw::from_c_str(bytes);
- JS_free(cx, cast::reinterpret_cast(&bytes));
+ let s = from_c_str(bytes);
+ JS_free(cx, reinterpret_cast(&bytes));
s
}
}
pub extern fn debug(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool {
- use io::WriterUtil;
+ use core::io::WriterUtil;
unsafe {
let argv = JS_ARGV(cx, vp);
View
3  glue.rs
@@ -1,7 +1,8 @@
/* automatically generated by rust-bindgen */
-use libc::*;
+use core::libc::*;
use jsapi::*;
+use jsfriendapi::JSJitInfo;
pub type enum_StubType = c_uint;
pub const PROPERTY_STUB: u32 = 0_u32;
View
26 js.rc
@@ -14,12 +14,12 @@ pub mod crust;
pub mod jsval;
pub mod jsfriendapi;
-use ptr::{null, addr_of};
-use result::{Result, Ok, Err};
-use libc::{c_char, c_uint};
+use core::ptr::{null, addr_of};
+use core::result::{Result, Ok, Err};
+use core::libc::{c_char, c_uint};
use name_pool::NamePool;
-use str::raw::from_c_str;
-use io::WriterUtil;
+use core::str::raw::from_c_str;
+use core::io::WriterUtil;
use jsapi::{JSBool, JSClass, JSContext, JSErrorReport, JSFunctionSpec,
JSObject, JSRuntime, JSString, JSVERSION_LATEST, JSVal, jsid,
JSPropertySpec, JSPropertyOp, JSStrictPropertyOp, JSProto_LIMIT};
@@ -32,14 +32,14 @@ use jsapi::bindgen::{JS_free, JS_AddObjectRoot, JS_DefineFunctions,
JS_SetErrorReporter, JS_SetOptions, JS_SetPrivate,
JS_SetVersion, JS_ValueToString, JS_DefineProperties,
JS_DefineProperty, JS_NewObject, JS_ComputeThis};
-use libc::types::common::c99::{int8_t, int16_t, int32_t, int64_t, uint8_t,
- uint16_t, uint32_t, uint64_t};
+use core::libc::types::common::c99::{int8_t, int16_t, int32_t, int64_t, uint8_t,
+ uint16_t, uint32_t, uint64_t};
use jsval::{JSVAL_TO_OBJECT, JSVAL_IS_PRIMITIVE};
use glue::bindgen::{RUST_JSVAL_TO_OBJECT, RUST_JSVAL_IS_PRIMITIVE};
use rust::jsobj;
-pub use rust;
+pub use mod rust;
-pub use NamePool;
+pub use name_pool::NamePool;
pub use mod jsapi;
pub use mod glue;
pub use mod crust;
@@ -195,20 +195,20 @@ mod shadow {
_1: *JSVal,
}
- impl Object {
+ pub impl Object {
#[inline(always)]
- pure fn numFixedSlots() -> libc::size_t {
+ pure fn numFixedSlots(&self) -> libc::size_t {
unsafe { ((*self.shape).slotInfo >> FIXED_SLOTS_SHIFT) as libc::size_t }
}
#[inline(always)]
- fn fixedSlots() -> *JSVal {
+ fn fixedSlots(&self) -> *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 {
+ pure fn slotVal(&self, slot: libc::size_t) -> JSVal {
unsafe {
let nfixed : libc::size_t = self.numFixedSlots();
if slot < nfixed {
View
2  jsapi.rs
@@ -1,6 +1,6 @@
/* automatically generated by rust-bindgen */
-use libc::*;
+use core::libc::*;
use jsfriendapi::JSJitInfo;
pub type moz_static_assert0 = c_int;
View
6 jsfriendapi.rs
@@ -16,11 +16,11 @@ pub struct JSJitInfo {
#[nolink]
pub extern mod bindgen {
pub fn DefineFunctionWithReserved(cx: *JSContext, obj: *JSObject,
- name: *libc::c_char, call: JSNative, nargs: uint,
- attrs: uint) -> *JSObject;
+ name: *libc::c_char, call: JSNative, nargs: libc::c_uint,
+ attrs: libc::c_uint) -> *JSObject;
pub fn GetObjectJSClass(obj: *JSObject) -> *JSClass;
pub fn js_GetErrorMessage(userRef: *libc::c_void, locale: *libc::c_char,
- errorNumber: uint) -> *JSErrorFormatString;
+ errorNumber: libc::c_uint) -> *JSErrorFormatString;
pub fn JS_NewObjectWithUniqueType(cx: *JSContext, clasp: *JSClass,
proto: *JSObject, parent: *JSObject) -> *JSObject;
}
View
6 name_pool.rs
@@ -1,5 +1,5 @@
-use libc::c_char;
-use vec::push;
+use core::libc::c_char;
+use core::vec::push;
pub struct NamePool {
strbufs: ~[~[u8]]
@@ -11,7 +11,7 @@ pub fn NamePool() -> @mut NamePool {
}
}
-impl NamePool {
+pub impl NamePool {
fn add(&mut self, s: ~str) -> *c_char {
unsafe {
let mut strbuf = ~[];
View
23 rust.rs
@@ -3,7 +3,8 @@
#[allow(non_implicitly_copyable_typarams)];
use bg = jsapi::bindgen;
-use libc::types::os::arch::c95::{size_t, c_uint};
+use core::libc::types::os::arch::c95::{size_t, c_uint};
+use core::libc::c_char;
use std::oldmap::HashMap;
use jsapi::*;
use jsapi::bindgen::*;
@@ -15,10 +16,10 @@ use JSOPTION_TYPE_INFERENCE;
use JSVAL_NULL;
use ERR;
use name_pool::*;
-use ptr::null;
+use core::ptr::null;
use result;
use result_obj;
-use str::raw::from_c_str;
+use core::str::raw::from_c_str;
// ___________________________________________________________________________
// friendly Rustic API to runtimes
@@ -40,8 +41,8 @@ pub fn new_runtime(p: *JSRuntime) -> rt {
}
}
-impl rt {
- fn cx() -> @Cx {
+pub impl rt {
+ fn cx(self) -> @Cx {
unsafe {
new_context(JS_NewContext(self.ptr, default_stacksize as size_t), self)
}
@@ -78,7 +79,7 @@ pub fn new_context(ptr: *JSContext, rt: rt) -> @Cx {
}
}
-impl Cx {
+pub impl Cx {
fn rooted_obj(@self, obj: *JSObject) -> jsobj {
let jsobj = @jsobj_rsrc {cx: self, cxptr: self.ptr, ptr: obj};
unsafe {
@@ -211,7 +212,7 @@ pub struct Compartment {
global_protos: HashMap<~str, jsobj>
}
-impl Compartment {
+pub impl Compartment {
fn define_functions(@mut self,
specfn: fn(@mut NamePool) -> ~[JSFunctionSpec])
-> Result<(),()> {
@@ -280,7 +281,7 @@ impl Compartment {
fn register_class(@mut self, class_fn: fn(x: @mut Compartment) -> JSClass) {
let classptr = @class_fn(self);
if !self.cx.classes.insert(
- unsafe { str::raw::from_c_str(classptr.name) },
+ unsafe { from_c_str(classptr.name) },
classptr) {
fail!(~"Duplicate JSClass registered; you're gonna have a bad time.")
}
@@ -307,7 +308,7 @@ pub struct jsobj_rsrc {
}
impl jsobj_rsrc {
- fn new_object(rec : {cx: @Cx, cxptr: *JSContext, ptr: *JSObject}) -> jsobj {
+ fn new_object(&self, rec : {cx: @Cx, cxptr: *JSContext, ptr: *JSObject}) -> jsobj {
return @jsobj_rsrc {
cx: rec.cx,
cxptr: rec.cxptr,
@@ -320,11 +321,11 @@ impl jsobj_rsrc {
// random utilities
pub trait to_jsstr {
- fn to_jsstr(cx: @Cx) -> *JSString;
+ fn to_jsstr(self, cx: @Cx) -> *JSString;
}
impl to_jsstr for ~str {
- fn to_jsstr(cx: @Cx) -> *JSString {
+ fn to_jsstr(self, cx: @Cx) -> *JSString {
str::as_buf(self, |buf, len| {
unsafe {
let cbuf = cast::reinterpret_cast(&buf);
Please sign in to comment.
Something went wrong with that request. Please try again.