missing files

This commit is contained in:
Niko Matsakis 2012-05-24 15:02:01 -07:00
parent 7bf5361a9a
commit fab592ce74
3 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,3 @@
type name_pool = {
};

View file

@ -0,0 +1,27 @@
import spidermonkey::jsapi::{JSContext, jsval};
impl methods<T: copy> for *T {
unsafe fn +(idx: uint) -> *T {
ptr::offset(self, idx)
}
unsafe fn [](idx: uint) -> T {
*(self + idx)
}
}
const JSVAL_VOID: u64 = 0x0001fff2_00000000_u64;
const JSVAL_NULL: u64 = 0x0001fff6_00000000_u64;
const JSVAL_ZERO: u64 = 0x0001fff1_00000000_u64;
const JSVAL_ONE: u64 = 0x0001fff1_00000001_u64;
const JSVAL_FALSE: u64 = 0x0001fff3_00000000_u64;
const JSVAL_TRUE: u64 = 0x0001fff3_00000001_u64;
unsafe fn JS_ARGV(_cx: *JSContext, vp: *jsval) -> *jsval {
vp + 2u
}
unsafe fn JS_SET_RVAL(_cx: *JSContext, vp: *jsval, v: jsval) {
let vp: *mut jsval = unsafe::reinterpret_cast(vp);
*vp = v;
}

View file

@ -0,0 +1,17 @@
import libc::c_char;
type name_pool = @{
mut strbufs: [str]
};
fn name_pool() -> name_pool {
@{mut strbufs: []}
}
impl methods for name_pool {
fn add(-s: str) -> *c_char {
let c_str = str::as_c_str(s) { |bytes| bytes };
self.strbufs += [s]; // in theory, this should *move* the str in here..
ret c_str; // ...and so this ptr ought to be valid.
}
}