mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Move Traceable, trace_reflector from utils.rs to trace.rs.(fixes #1748)
This commit is contained in:
parent
98170e67c0
commit
f706123208
3 changed files with 26 additions and 22 deletions
|
@ -5339,6 +5339,7 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::types::*',
|
'dom::types::*',
|
||||||
'dom::bindings::js::JS',
|
'dom::bindings::js::JS',
|
||||||
'dom::bindings::utils::*',
|
'dom::bindings::utils::*',
|
||||||
|
'dom::bindings::trace::Traceable',
|
||||||
'dom::bindings::callback::*',
|
'dom::bindings::callback::*',
|
||||||
'dom::bindings::conversions::*',
|
'dom::bindings::conversions::*',
|
||||||
'dom::bindings::codegen::*', #XXXjdm
|
'dom::bindings::codegen::*', #XXXjdm
|
||||||
|
@ -6353,7 +6354,7 @@ class GlobalGenRoots():
|
||||||
allprotos = [CGGeneric(declare="#[allow(unused_imports)];\n"),
|
allprotos = [CGGeneric(declare="#[allow(unused_imports)];\n"),
|
||||||
CGGeneric(declare="use dom::types::*;\n"),
|
CGGeneric(declare="use dom::types::*;\n"),
|
||||||
CGGeneric(declare="use dom::bindings::js::JS;\n"),
|
CGGeneric(declare="use dom::bindings::js::JS;\n"),
|
||||||
CGGeneric(declare="use dom::bindings::utils::Traceable;\n"),
|
CGGeneric(declare="use dom::bindings::trace::Traceable;\n"),
|
||||||
CGGeneric(declare="use extra::serialize::{Encodable, Encoder};\n"),
|
CGGeneric(declare="use extra::serialize::{Encodable, Encoder};\n"),
|
||||||
CGGeneric(declare="use js::jsapi::JSTracer;\n\n")]
|
CGGeneric(declare="use js::jsapi::JSTracer;\n\n")]
|
||||||
for descriptor in descriptors:
|
for descriptor in descriptors:
|
||||||
|
|
|
@ -3,11 +3,14 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::js::JS;
|
use dom::bindings::js::JS;
|
||||||
use dom::bindings::utils::{Reflectable, trace_reflector, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
|
|
||||||
use js::jsapi::JSTracer;
|
use js::jsapi::{JSTracer, JS_CallTracer, JSTRACE_OBJECT};
|
||||||
|
|
||||||
use std::cast;
|
use std::cast;
|
||||||
|
use std::libc;
|
||||||
|
use std::ptr;
|
||||||
|
use std::ptr::null;
|
||||||
use extra::serialize::{Encodable, Encoder};
|
use extra::serialize::{Encodable, Encoder};
|
||||||
|
|
||||||
// IMPORTANT: We rely on the fact that we never attempt to encode DOM objects using
|
// IMPORTANT: We rely on the fact that we never attempt to encode DOM objects using
|
||||||
|
@ -26,3 +29,20 @@ impl<S: Encoder> Encodable<S> for Reflector {
|
||||||
fn encode(&self, _s: &mut S) {
|
fn encode(&self, _s: &mut S) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait Traceable {
|
||||||
|
fn trace(&self, trc: *mut JSTracer);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
|
||||||
|
unsafe {
|
||||||
|
description.to_c_str().with_ref(|name| {
|
||||||
|
(*tracer).debugPrinter = ptr::null();
|
||||||
|
(*tracer).debugPrintIndex = -1;
|
||||||
|
(*tracer).debugPrintArg = name as *libc::c_void;
|
||||||
|
debug!("tracing {:s}", description);
|
||||||
|
JS_CallTracer(tracer as *JSTracer, reflector.get_jsobject(),
|
||||||
|
JSTRACE_OBJECT as u32);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ use js::jsapi::{JS_GetFunctionPrototype, JS_InternString, JS_GetFunctionObject};
|
||||||
use js::jsapi::{JS_HasPropertyById, JS_GetPrototype, JS_GetGlobalForObject};
|
use js::jsapi::{JS_HasPropertyById, JS_GetPrototype, JS_GetGlobalForObject};
|
||||||
use js::jsapi::{JS_NewUCStringCopyN, JS_DefineFunctions, JS_DefineProperty};
|
use js::jsapi::{JS_NewUCStringCopyN, JS_DefineFunctions, JS_DefineProperty};
|
||||||
use js::jsapi::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot};
|
use js::jsapi::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot};
|
||||||
use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative, JSTracer};
|
use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative};
|
||||||
use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor};
|
use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor};
|
||||||
use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses};
|
use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses};
|
||||||
use js::jsapi::{JSString, JS_CallTracer, JSTRACE_OBJECT};
|
use js::jsapi::{JSString};
|
||||||
use js::jsapi::{JS_IsExceptionPending, JS_AllowGC, JS_InhibitGC};
|
use js::jsapi::{JS_IsExceptionPending, JS_AllowGC, JS_InhibitGC};
|
||||||
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
||||||
use js::{JSPROP_ENUMERATE, JSVAL_NULL, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
|
use js::{JSPROP_ENUMERATE, JSVAL_NULL, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
|
||||||
|
@ -556,23 +556,6 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: c_uint, _vp: *mut JSVa
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Traceable {
|
|
||||||
fn trace(&self, trc: *mut JSTracer);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) {
|
|
||||||
unsafe {
|
|
||||||
description.to_c_str().with_ref(|name| {
|
|
||||||
(*tracer).debugPrinter = ptr::null();
|
|
||||||
(*tracer).debugPrintIndex = -1;
|
|
||||||
(*tracer).debugPrintArg = name as *libc::c_void;
|
|
||||||
debug!("tracing {:s}", description);
|
|
||||||
JS_CallTracer(tracer as *JSTracer, reflector.get_jsobject(),
|
|
||||||
JSTRACE_OBJECT as u32);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn initialize_global(global: *JSObject) {
|
pub fn initialize_global(global: *JSObject) {
|
||||||
let protoArray = @mut ([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]);
|
let protoArray = @mut ([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue