Skip to content

Commit

Permalink
missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed May 24, 2012
1 parent 7bf5361 commit fab592c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/servo/content/jsnames.rs
@@ -0,0 +1,3 @@
type name_pool = {

};
27 changes: 27 additions & 0 deletions src/servo/content/jsutil.rs
@@ -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;
}

17 changes: 17 additions & 0 deletions src/servo/content/name_pool.rs
@@ -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.
}
}

0 comments on commit fab592c

Please sign in to comment.