diff --git a/src/servo/content/jsnames.rs b/src/servo/content/jsnames.rs new file mode 100644 index 00000000000..aad0e631cef --- /dev/null +++ b/src/servo/content/jsnames.rs @@ -0,0 +1,3 @@ +type name_pool = { + +}; \ No newline at end of file diff --git a/src/servo/content/jsutil.rs b/src/servo/content/jsutil.rs new file mode 100644 index 00000000000..169d88ac01e --- /dev/null +++ b/src/servo/content/jsutil.rs @@ -0,0 +1,27 @@ +import spidermonkey::jsapi::{JSContext, jsval}; + +impl methods 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; +} + diff --git a/src/servo/content/name_pool.rs b/src/servo/content/name_pool.rs new file mode 100644 index 00000000000..7b39866ec4f --- /dev/null +++ b/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. + } +} \ No newline at end of file