Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move debug functions to Window IDL. #2381

Merged
merged 1 commit into from May 9, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

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.
  • Loading branch information
Ms2ger committed May 9, 2014
commit 30055d98205488431939f66020a70f8e4da960c7
@@ -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();
};
@@ -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 {
@@ -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();
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.