mirror of
https://github.com/servo/servo.git
synced 2025-06-13 02:44:29 +00:00
Add safe JSontext wrapper around unsafe RawJSContext
This commit is contained in:
parent
5d85f60f7d
commit
dbcd8d7af2
1 changed files with 19 additions and 0 deletions
|
@ -748,3 +748,22 @@ unsafe fn set_gc_zeal_options(cx: *mut RawJSContext) {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
#[cfg(not(feature = "debugmozjs"))]
|
#[cfg(not(feature = "debugmozjs"))]
|
||||||
unsafe fn set_gc_zeal_options(_: *mut RawJSContext) {}
|
unsafe fn set_gc_zeal_options(_: *mut RawJSContext) {}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct JSContext(*mut RawJSContext);
|
||||||
|
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
impl JSContext {
|
||||||
|
pub unsafe fn from_ptr(raw_js_context: *mut RawJSContext) -> Self {
|
||||||
|
JSContext(raw_js_context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unsafe_code)]
|
||||||
|
impl Deref for JSContext {
|
||||||
|
type Target = *mut RawJSContext;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue