зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #2050 - Remove XRay related stuff from codegen (fixes #1936) (from sankha93:rmxray); r=Ms2ger
Source-Repo: https://github.com/servo/servo Source-Revision: 86c83f7bfc2c748047dbd9b2d4b788e77714c980
This commit is contained in:
Родитель
3a82c9b491
Коммит
e5c1703a35
|
@ -1515,27 +1515,6 @@ class ConstDefiner(PropertyDefiner):
|
||||||
'ConstantSpec',
|
'ConstantSpec',
|
||||||
PropertyDefiner.getControllingPref, specData, doIdArrays)
|
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
|
# 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
|
# don't want to indent empty lines. So only indent lines that have a
|
||||||
# non-newline character on them.
|
# non-newline character on them.
|
||||||
|
@ -1646,8 +1625,7 @@ def DOMClass(descriptor):
|
||||||
protoList.extend(['PrototypeList::id::IDCount'] * (descriptor.config.maxProtoChainLength - len(protoList)))
|
protoList.extend(['PrototypeList::id::IDCount'] * (descriptor.config.maxProtoChainLength - len(protoList)))
|
||||||
prototypeChainString = ', '.join(protoList)
|
prototypeChainString = ', '.join(protoList)
|
||||||
return """DOMClass {
|
return """DOMClass {
|
||||||
interface_chain: [ %s ],
|
interface_chain: [ %s ]
|
||||||
native_hooks: &NativeHooks as *NativePropertyHooks
|
|
||||||
}""" % prototypeChainString
|
}""" % prototypeChainString
|
||||||
|
|
||||||
class CGDOMJSClass(CGThing):
|
class CGDOMJSClass(CGThing):
|
||||||
|
@ -2326,11 +2304,6 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
""" % (FINALIZE_HOOK_NAME,
|
""" % (FINALIZE_HOOK_NAME,
|
||||||
('Some(%s)' % TRACE_HOOK_NAME),
|
('Some(%s)' % TRACE_HOOK_NAME),
|
||||||
self.descriptor.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;
|
return (body + """ let cx = js_info.js_context.deref().ptr;
|
||||||
let receiver = js_info.js_compartment.global_obj;
|
let receiver = js_info.js_compartment.global_obj;
|
||||||
|
@ -3692,72 +3665,6 @@ class CGClass(CGThing):
|
||||||
result += "}"
|
result += "}"
|
||||||
return 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):
|
class CGProxySpecialOperation(CGPerSignatureCall):
|
||||||
"""
|
"""
|
||||||
Base class for classes for calling an indexed or named special operation
|
Base class for classes for calling an indexed or named special operation
|
||||||
|
@ -4301,25 +4208,12 @@ class CGDescriptor(CGThing):
|
||||||
CGConstant(m for m in descriptor.interface.members if m.isConst()),
|
CGConstant(m for m in descriptor.interface.members if m.isConst()),
|
||||||
public=True))
|
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():
|
if descriptor.interface.hasInterfaceObject():
|
||||||
cgThings.append(CGDefineDOMInterfaceMethod(descriptor))
|
cgThings.append(CGDefineDOMInterfaceMethod(descriptor))
|
||||||
if (descriptor.interface.getExtendedAttribute("PrefControlled") is not None):
|
if (descriptor.interface.getExtendedAttribute("PrefControlled") is not None):
|
||||||
#cgThings.append(CGPrefEnabled(descriptor))
|
#cgThings.append(CGPrefEnabled(descriptor))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if descriptor.interface.hasInterfacePrototypeObject():
|
|
||||||
cgThings.append(CGNativePropertyHooks(descriptor))
|
|
||||||
pass
|
|
||||||
|
|
||||||
if descriptor.concrete:
|
if descriptor.concrete:
|
||||||
if descriptor.proxy:
|
if descriptor.proxy:
|
||||||
#cgThings.append(CGProxyIsProxy(descriptor))
|
#cgThings.append(CGProxyIsProxy(descriptor))
|
||||||
|
@ -4745,13 +4639,12 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}',
|
'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}',
|
||||||
'dom::bindings::utils::{HasPropertyOnPrototype, IntVal}',
|
'dom::bindings::utils::{HasPropertyOnPrototype, IntVal}',
|
||||||
'dom::bindings::utils::{jsid_to_str}',
|
'dom::bindings::utils::{jsid_to_str}',
|
||||||
'dom::bindings::utils::{NativePropertyHooks}',
|
|
||||||
'dom::bindings::utils::global_object_for_js_object',
|
'dom::bindings::utils::global_object_for_js_object',
|
||||||
'dom::bindings::utils::{Reflectable}',
|
'dom::bindings::utils::{Reflectable}',
|
||||||
'dom::bindings::utils::{squirrel_away_unique}',
|
'dom::bindings::utils::{squirrel_away_unique}',
|
||||||
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
|
'dom::bindings::utils::{ThrowingConstructor, unwrap, unwrap_jsmanaged}',
|
||||||
'dom::bindings::utils::{unwrap_object, VoidVal, with_gc_disabled}',
|
'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::trace::Traceable',
|
||||||
'dom::bindings::callback::{CallbackContainer,CallbackInterface}',
|
'dom::bindings::callback::{CallbackContainer,CallbackInterface}',
|
||||||
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
|
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
|
||||||
|
|
|
@ -24,11 +24,11 @@ use js::jsapi::{JS_DefineProperties, JS_ForwardGetPropertyTo};
|
||||||
use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength};
|
use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype, JS_GetStringCharsAndLength};
|
||||||
use js::jsapi::{JS_ObjectIsRegExp, JS_ObjectIsDate};
|
use js::jsapi::{JS_ObjectIsRegExp, JS_ObjectIsDate};
|
||||||
use js::jsapi::{JS_InternString, JS_GetFunctionObject};
|
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_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};
|
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::{JS_NewGlobalObject, JS_InitStandardClasses};
|
||||||
use js::jsapi::{JSString};
|
use js::jsapi::{JSString};
|
||||||
use js::jsapi::{JS_AllowGC, JS_InhibitGC};
|
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::{PrivateValue, ObjectValue, NullValue, Int32Value};
|
||||||
use js::jsval::{UInt32Value, DoubleValue, BooleanValue, UndefinedValue};
|
use js::jsval::{UInt32Value, DoubleValue, BooleanValue, UndefinedValue};
|
||||||
use js::{JSPROP_ENUMERATE, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
|
use js::{JSPROP_ENUMERATE, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
|
||||||
use js::{JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER};
|
use js::JSPROP_PERMANENT;
|
||||||
use js::JSPROP_SETTER;
|
|
||||||
use js::{JSFUN_CONSTRUCTOR, JSPROP_READONLY};
|
use js::{JSFUN_CONSTRUCTOR, JSPROP_READONLY};
|
||||||
use js;
|
use js;
|
||||||
|
|
||||||
pub struct GlobalStaticData {
|
pub struct GlobalStaticData {
|
||||||
proxy_handlers: HashMap<uint, *libc::c_void>,
|
proxy_handlers: HashMap<uint, *libc::c_void>
|
||||||
attribute_ids: HashMap<uint, ~[jsid]>,
|
|
||||||
method_ids: HashMap<uint, ~[jsid]>,
|
|
||||||
constant_ids: HashMap<uint, ~[jsid]>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GlobalStaticData() -> GlobalStaticData {
|
pub fn GlobalStaticData() -> GlobalStaticData {
|
||||||
GlobalStaticData {
|
GlobalStaticData {
|
||||||
proxy_handlers: HashMap::new(),
|
proxy_handlers: HashMap::new()
|
||||||
attribute_ids: HashMap::new(),
|
|
||||||
method_ids: HashMap::new(),
|
|
||||||
constant_ids: HashMap::new()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,40 +160,6 @@ pub static DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT;
|
||||||
// changes.
|
// changes.
|
||||||
pub static JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1;
|
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)]
|
#[deriving(Clone)]
|
||||||
pub enum ConstantVal {
|
pub enum ConstantVal {
|
||||||
IntVal(i32),
|
IntVal(i32),
|
||||||
|
@ -220,9 +179,7 @@ pub struct ConstantSpec {
|
||||||
pub struct DOMClass {
|
pub struct DOMClass {
|
||||||
// A list of interfaces that this object implements, in order of decreasing
|
// A list of interfaces that this object implements, in order of decreasing
|
||||||
// derivedness.
|
// derivedness.
|
||||||
interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH],
|
interface_chain: [PrototypeList::id::ID, ..MAX_PROTO_CHAIN_LENGTH]
|
||||||
|
|
||||||
native_hooks: *NativePropertyHooks
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DOMJSClass {
|
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> {
|
fn InternJSString(cx: *JSContext, chars: *libc::c_char) -> Option<jsid> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let s = JS_InternString(cx, chars);
|
let s = JS_InternString(cx, chars);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче