aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSankha Narayan Guria <sankha93@gmail.com>2014-04-07 02:03:41 +0530
committerSankha Narayan Guria <sankha93@gmail.com>2014-04-07 02:27:53 +0530
commit9a4bec304f2717bf095274ab3a45fb20e35d6bac (patch)
tree44442593e9d0e28c102d5f936d156aa6c49efa20
parent4386bae5763802346012c308646d7c39606f68ea (diff)
downloadservo-9a4bec304f2717bf095274ab3a45fb20e35d6bac.tar.gz
servo-9a4bec304f2717bf095274ab3a45fb20e35d6bac.zip
Remove XRay related stuff from codegen (fixes #1936)
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py111
-rw-r--r--src/components/script/dom/bindings/utils.rs104
2 files changed, 8 insertions, 207 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index cce35ffce82..b78bb37ffff 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1525,27 +1525,6 @@ class ConstDefiner(PropertyDefiner):
'ConstantSpec',
PropertyDefiner.getControllingPref, specData, doIdArrays)
-class CGNativePropertyHooks(CGThing):
- """
- Generate a NativePropertyHooks for a given descriptor
- """
- def __init__(self, descriptor):
- CGThing.__init__(self)
- self.descriptor = descriptor
-
- def define(self):
- if self.descriptor.concrete and self.descriptor.proxy:
- resolveOwnProperty = "ResolveOwnProperty"
- enumerateOwnProperties = "EnumerateOwnProperties"
- else:
- enumerateOwnProperties = resolveOwnProperty = "0 as *u8"
- parent = self.descriptor.interface.parent
- parentHooks = ("&" + toBindingNamespace(parent.identifier.name) + "::NativeHooks"
- if parent else '0 as *NativePropertyHooks')
- return """
-static NativeHooks: NativePropertyHooks = NativePropertyHooks { resolve_own_property: /*%s*/ 0 as *u8, resolve_property: ResolveProperty, enumerate_own_properties: /*%s*/ 0 as *u8, enumerate_properties: /*EnumerateProperties*/ 0 as *u8, proto_hooks: /*%s*/ 0 as *NativePropertyHooks };
-""" % (resolveOwnProperty, enumerateOwnProperties, parentHooks)
-
# We'll want to insert the indent at the beginnings of lines, but we
# don't want to indent empty lines. So only indent lines that have a
# non-newline character on them.
@@ -1656,8 +1635,7 @@ def DOMClass(descriptor):
protoList.extend(['PrototypeList::id::IDCount'] * (descriptor.config.maxProtoChainLength - len(protoList)))
prototypeChainString = ', '.join(protoList)
return """DOMClass {
- interface_chain: [ %s ],
- native_hooks: &NativeHooks as *NativePropertyHooks
+ interface_chain: [ %s ]
}""" % prototypeChainString
class CGDOMJSClass(CGThing):
@@ -2336,11 +2314,6 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
""" % (FINALIZE_HOOK_NAME,
('Some(%s)' % TRACE_HOOK_NAME),
self.descriptor.name)
- else:
- body += """ js_info.dom_static.attribute_ids.insert(PrototypeList::id::%s as uint,
- slice::cast_to_mut(slice::from_slice(sAttributes_ids)));
-""" % self.descriptor.name
- body = "" #XXXjdm xray stuff isn't necessary yet
return (body + """ let cx = js_info.js_context.deref().ptr;
let receiver = js_info.js_compartment.global_obj;
@@ -3685,72 +3658,6 @@ class CGClass(CGThing):
result += "}"
return result
-
-class CGXrayHelper(CGAbstractExternMethod):
- def __init__(self, descriptor, name, args, properties):
- CGAbstractExternMethod.__init__(self, descriptor, name, "bool", args)
- self.properties = properties
-
- def definition_body(self):
- varNames = self.properties.variableNames(True)
-
- setup = ("let window = global_object_for_js_object(wrapper);\n"
- "let js_info = window.get().page().js_info();\n")
-
- methods = self.properties.methods
- if methods.hasNonChromeOnly() or methods.hasChromeOnly():
- methodArgs = "Some(zip_copies(%(methods)s, *method_ids))" % varNames
- setup += "let method_ids = js_info.get_ref().dom_static.method_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
- else:
- methodArgs = "None"
- methodArgs = CGGeneric(methodArgs)
-
- attrs = self.properties.attrs
- if attrs.hasNonChromeOnly() or attrs.hasChromeOnly():
- attrArgs = "Some(zip_copies(%(attrs)s, *attr_ids))" % varNames
- setup += "let attr_ids = js_info.get_ref().dom_static.attribute_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
- else:
- attrArgs = "None"
- attrArgs = CGGeneric(attrArgs)
-
- consts = self.properties.consts
- if consts.hasNonChromeOnly() or consts.hasChromeOnly():
- constArgs = "Some(zip_copies(%(consts)s, *const_ids))" % varNames
- setup += "let const_ids = js_info.get_ref().dom_static.constant_ids.get(&(PrototypeList::id::ClientRect as uint));\n"
- else:
- constArgs = "None"
- constArgs = CGGeneric(constArgs)
-
- prefixArgs = CGGeneric(self.getPrefixArgs())
-
- return CGIndenter(
- CGWrapper(CGList([prefixArgs, methodArgs, attrArgs, constArgs], ", "),
- pre=(setup + "return Xray%s(" % self.name),
- post=");",
- reindent=True)).define()
-
-class CGResolveProperty(CGXrayHelper):
- def __init__(self, descriptor, properties):
- args = [Argument('*JSContext', 'cx'), Argument('*JSObject', 'wrapper'),
- Argument('jsid', 'id'), Argument('bool', 'set'),
- Argument('*mut JSPropertyDescriptor', 'desc')]
- CGXrayHelper.__init__(self, descriptor, "ResolveProperty", args,
- properties)
-
- def getPrefixArgs(self):
- return "cx, wrapper, id, desc"
-
-
-class CGEnumerateProperties(CGXrayHelper):
- def __init__(self, descriptor, properties):
- args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'wrapper'),
- Argument('JS::AutoIdVector&', 'props')]
- CGXrayHelper.__init__(self, descriptor, "EnumerateProperties", args,
- properties)
-
- def getPrefixArgs(self):
- return "props"
-
class CGProxySpecialOperation(CGPerSignatureCall):
"""
Base class for classes for calling an indexed or named special operation
@@ -4294,25 +4201,12 @@ class CGDescriptor(CGThing):
CGConstant(m for m in descriptor.interface.members if m.isConst()),
public=True))
- # Set up our Xray callbacks as needed.
- if descriptor.interface.hasInterfacePrototypeObject():
- if descriptor.concrete and descriptor.proxy:
- #cgThings.append(CGResolveOwnProperty(descriptor))
- #cgThings.append(CGEnumerateOwnProperties(descriptor))
- pass
- cgThings.append(CGResolveProperty(descriptor, properties))
- #cgThings.append(CGEnumerateProperties(descriptor, properties))
-
if descriptor.interface.hasInterfaceObject():
cgThings.append(CGDefineDOMInterfaceMethod(descriptor))
if (descriptor.interface.getExtendedAttribute("PrefControlled") is not None):
#cgThings.append(CGPrefEnabled(descriptor))
pass
- if descriptor.interface.hasInterfacePrototypeObject():
- cgThings.append(CGNativePropertyHooks(descriptor))
- pass
-
if descriptor.concrete:
if descriptor.proxy:
#cgThings.append(CGProxyIsProxy(descriptor))
@@ -4746,13 +4640,12 @@ class CGBindingRoot(CGThing):
'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}',
'dom::bindings::utils::{HasPropertyOnPrototype, IntVal}',
'dom::bindings::utils::{jsid_to_str}',
- 'dom::bindings::utils::{NativePropertyHooks}',
'dom::bindings::utils::global_object_for_js_object',
'dom::bindings::utils::{Reflectable}',
'dom::bindings::utils::{squirrel_away_unique}',
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
'dom::bindings::utils::{unwrap_object, VoidVal, with_gc_disabled}',
- 'dom::bindings::utils::{with_gc_enabled, XrayResolveProperty}',
+ 'dom::bindings::utils::{with_gc_enabled}',
'dom::bindings::trace::Traceable',
'dom::bindings::callback::{CallbackContainer,CallbackInterface}',
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs
index db6cb3290d7..60afa484e0c 100644
--- a/src/components/script/dom/bindings/utils.rs
+++ b/src/components/script/dom/bindings/utils.rs
@@ -24,11 +24,11 @@ use js::jsapi::{JS_DefineProperties, JS_ForwardGetPropertyTo};
use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength};
use js::jsapi::{JS_ObjectIsRegExp, JS_ObjectIsDate};
use js::jsapi::{JS_InternString, JS_GetFunctionObject};
-use js::jsapi::{JS_HasPropertyById, JS_GetPrototype, JS_GetGlobalForObject};
+use js::jsapi::{JS_HasPropertyById, JS_GetPrototype};
use js::jsapi::{JS_DefineFunctions, JS_DefineProperty};
use js::jsapi::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot};
use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative};
-use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSPropertyDescriptor};
+use js::jsapi::{JSFunctionSpec, JSPropertySpec};
use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses};
use js::jsapi::{JSString};
use js::jsapi::{JS_AllowGC, JS_InhibitGC};
@@ -37,24 +37,17 @@ use js::jsval::JSVal;
use js::jsval::{PrivateValue, ObjectValue, NullValue, Int32Value};
use js::jsval::{UInt32Value, DoubleValue, BooleanValue, UndefinedValue};
use js::{JSPROP_ENUMERATE, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
-use js::{JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER};
-use js::JSPROP_SETTER;
+use js::JSPROP_PERMANENT;
use js::{JSFUN_CONSTRUCTOR, JSPROP_READONLY};
use js;
pub struct GlobalStaticData {
- proxy_handlers: HashMap<uint, *libc::c_void>,
- attribute_ids: HashMap<uint, ~[jsid]>,
- method_ids: HashMap<uint, ~[jsid]>,
- constant_ids: HashMap<uint, ~[jsid]>
+ proxy_handlers: HashMap<uint, *libc::c_void>
}
pub fn GlobalStaticData() -> GlobalStaticData {
GlobalStaticData {
- proxy_handlers: HashMap::new(),
- attribute_ids: HashMap::new(),
- method_ids: HashMap::new(),
- constant_ids: HashMap::new()
+ proxy_handlers: HashMap::new()
}
}
@@ -167,40 +160,6 @@ pub static DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT;
// changes.
pub static JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1;
-pub struct NativeProperties {
- staticMethods: *JSFunctionSpec,
- staticMethodIds: *jsid,
- staticMethodsSpecs: *JSFunctionSpec,
- staticAttributes: *JSPropertySpec,
- staticAttributeIds: *jsid,
- staticAttributeSpecs: *JSPropertySpec,
- methods: *JSFunctionSpec,
- methodIds: *jsid,
- methodsSpecs: *JSFunctionSpec,
- attributes: *JSPropertySpec,
- attributeIds: *jsid,
- attributeSpecs: *JSPropertySpec,
- unforgeableAttributes: *JSPropertySpec,
- unforgeableAttributeIds: *jsid,
- unforgeableAttributeSpecs: *JSPropertySpec,
- constants: *ConstantSpec,
- constantIds: *jsid,
- constantSpecs: *ConstantSpec
-}
-
-pub struct NativePropertyHooks {
- resolve_own_property: *u8,
- resolve_property: extern "C" fn(*JSContext, *JSObject, jsid, bool, *mut JSPropertyDescriptor) -> bool,
- enumerate_own_properties: *u8,
- enumerate_properties: *u8,
- proto_hooks: *NativePropertyHooks
-}
-
-pub struct JSNativeHolder {
- native: js::jsapi::JSNative,
- propertyHooks: *NativePropertyHooks
-}
-
#[deriving(Clone)]
pub enum ConstantVal {
IntVal(i32),
@@ -220,9 +179,7 @@ pub struct ConstantSpec {
pub struct DOMClass {
// A list of interfaces that this object implements, in order of decreasing
// derivedness.
- interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH],
-
- native_hooks: *NativePropertyHooks
+ interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH]
}
pub struct DOMJSClass {
@@ -491,55 +448,6 @@ pub fn GetArrayIndexFromId(_cx: *JSContext, id: jsid) -> Option<u32> {
}*/
}
-pub fn XrayResolveProperty(cx: *JSContext,
- wrapper: *JSObject,
- id: jsid,
- desc: *mut JSPropertyDescriptor,
- _methods: Option<~[(JSFunctionSpec, jsid)]>,
- attributes: Option<~[(JSPropertySpec, jsid)]>,
- _constants: Option<~[(ConstantSpec, jsid)]>) -> bool
-{
- unsafe {
- match attributes {
- Some(attrs) => {
- for &elem in attrs.iter() {
- let (attr, attr_id) = elem;
- if attr_id == JSID_VOID || attr_id != id {
- continue;
- }
-
- (*desc).attrs = (attr.flags & !(JSPROP_NATIVE_ACCESSORS as u8)) as u32;
- let global = JS_GetGlobalForObject(cx, wrapper);
- let fun = JS_NewFunction(cx, attr.getter.op, 0, 0, global, ptr::null());
- if fun.is_null() {
- return false;
- }
-
- RUST_SET_JITINFO(fun, attr.getter.info);
- let funobj = JS_GetFunctionObject(fun);
- (*desc).getter = Some(cast::transmute(funobj));
- (*desc).attrs |= JSPROP_GETTER;
- if attr.setter.op.is_some() {
- let fun = JS_NewFunction(cx, attr.setter.op, 1, 0, global, ptr::null());
- if fun.is_null() {
- return false
- }
-
- RUST_SET_JITINFO(fun, attr.setter.info);
- let funobj = JS_GetFunctionObject(fun);
- (*desc).setter = Some(cast::transmute(funobj));
- (*desc).attrs |= JSPROP_SETTER;
- } else {
- (*desc).setter = None;
- }
- }
- }
- None => ()
- }
- return true;
- }
-}
-
fn InternJSString(cx: *JSContext, chars: *libc::c_char) -> Option<jsid> {
unsafe {
let s = JS_InternString(cx, chars);