Move debug functions to Window IDL.

This is a cleaner way to expose those functions, and makes it possible to
remove a significant amount code in rust-mozjs.

The assert() function is no longer exposed, as it was unused and not very
useful.
This commit is contained in:
Ms2ger 2014-05-09 14:44:07 +02:00
parent 052d3cb083
commit 30055d9820
4 changed files with 21 additions and 10 deletions

View file

@ -84,3 +84,9 @@ interface WindowTimers {
void clearInterval(optional long handle = 0);*/
};
Window implements WindowTimers;
// Proprietary extensions.
partial interface Window {
void debug(DOMString arg);
void gc();
};

View file

@ -23,6 +23,7 @@ use servo_util::str::DOMString;
use servo_util::task::{spawn_named};
use js::jsapi::JSContext;
use js::jsapi::{JS_GC, JS_GetRuntime};
use js::jsval::{NullValue, JSVal};
use collections::hashmap::HashMap;
@ -138,6 +139,8 @@ pub trait WindowMethods {
fn Window(&self) -> Temporary<Window>;
fn Self(&self) -> Temporary<Window>;
fn Performance(&mut self) -> Temporary<Performance>;
fn Debug(&self, message: DOMString);
fn Gc(&self);
}
impl<'a> WindowMethods for JSRef<'a, Window> {
@ -263,6 +266,16 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
}
Temporary::new(self.performance.get_ref().clone())
}
fn Debug(&self, message: DOMString) {
debug!("{:s}", message);
}
fn Gc(&self) {
unsafe {
JS_GC(JS_GetRuntime(self.get_cx()));
}
}
}
impl Reflectable for Window {

View file

@ -34,8 +34,7 @@ use layout_interface;
use geom::point::Point2D;
use geom::size::Size2D;
use js::global::DEBUG_FNS;
use js::jsapi::{JS_CallFunctionValue, JS_DefineFunctions};
use js::jsapi::JS_CallFunctionValue;
use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ, JS_GC};
use js::jsapi::{JSContext, JSRuntime};
use js::jsval::NullValue;
@ -1004,13 +1003,6 @@ impl ScriptTask {
debug!("js_scripts: {:?}", js_scripts);
with_compartment((**cx).ptr, window.reflector().get_jsobject(), || {
// Define debug functions.
unsafe {
assert!(JS_DefineFunctions((**cx).ptr,
window.reflector().get_jsobject(),
DEBUG_FNS.as_ptr()) != 0);
}
// Evaluate every script in the document.
for file in js_scripts.iter() {
let global_obj = window.reflector().get_jsobject();

@ -1 +1 @@
Subproject commit 50365a556b51da2455de051bfe4697872f49d8df
Subproject commit 07acb44df9b3f638743931f392c0ebe7040a7bab