Bug 1769588 - Remove unused NativePropertyHooks::mProtoHooks. r=edgar

Differential Revision: https://phabricator.services.mozilla.com/D146465
This commit is contained in:
Peter Van der Beken 2022-05-18 09:01:42 +00:00
Родитель ffb083dccd
Коммит e948d549b0
2 изменённых файлов: 48 добавлений и 71 удалений

Просмотреть файл

@ -470,28 +470,14 @@ class CGNativePropertyHooks(CGThing):
def __init__(self, descriptor, properties):
CGThing.__init__(self)
assert descriptor.wantsXrays
self.descriptor = descriptor
self.properties = properties
def declare(self):
if not self.descriptor.wantsXrays:
return ""
return dedent(
"""
// We declare this as an array so that retrieving a pointer to this
// binding's property hooks only requires compile/link-time resolvable
// address arithmetic. Declaring it as a pointer instead would require
// doing a run-time load to fetch a pointer to this binding's property
// hooks. And then structures which embedded a pointer to this structure
// would require a run-time load for proper initialization, which would
// then induce static constructors. Lots of static constructors.
extern const NativePropertyHooks sNativePropertyHooks[];
"""
)
return ""
def define(self):
if not self.descriptor.wantsXrays:
return ""
deleteNamedProperty = "nullptr"
if (
self.descriptor.concrete
@ -526,12 +512,6 @@ class CGNativePropertyHooks(CGThing):
prototypeID += self.descriptor.name
else:
prototypeID += "_ID_Count"
parentProtoName = self.descriptor.parentPrototypeName
parentHooks = (
toBindingNamespace(parentProtoName) + "::sNativePropertyHooks"
if parentProtoName
else "nullptr"
)
if self.descriptor.wantsXrayExpandoClass:
expandoClass = "&sXrayExpandoObjectClass"
@ -541,16 +521,15 @@ class CGNativePropertyHooks(CGThing):
return fill(
"""
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks[] = { {
const NativePropertyHooks sNativePropertyHooks = {
${resolveOwnProperty},
${enumerateOwnProperties},
${deleteNamedProperty},
{ ${regular}, ${chrome}, &sNativePropertiesInited },
${prototypeID},
${constructorID},
${parentHooks},
${expandoClass}
} };
};
""",
resolveOwnProperty=resolveOwnProperty,
enumerateOwnProperties=enumerateOwnProperties,
@ -559,7 +538,6 @@ class CGNativePropertyHooks(CGThing):
chrome=chrome,
prototypeID=prototypeID,
constructorID=constructorID,
parentHooks=parentHooks,
expandoClass=expandoClass,
)
@ -568,7 +546,7 @@ def NativePropertyHooks(descriptor):
return (
"&sEmptyNativePropertyHooks"
if not descriptor.wantsXrays
else "sNativePropertyHooks"
else "&sNativePropertyHooks"
)
@ -16376,6 +16354,49 @@ class CGDescriptor(CGThing):
CGCollectJSONAttributesMethod(descriptor, defaultToJSONMethod)
)
# Declare our DOMProxyHandler.
if descriptor.concrete and descriptor.proxy:
cgThings.append(
CGGeneric(
fill(
"""
static_assert(std::is_base_of_v<nsISupports, ${nativeType}>,
"We don't support non-nsISupports native classes for "
"proxy-based bindings yet");
""",
nativeType=descriptor.nativeType,
)
)
)
if not descriptor.wrapperCache:
raise TypeError(
"We need a wrappercache to support expandos for proxy-based "
"bindings (" + descriptor.name + ")"
)
handlerThing = CGDOMJSProxyHandler(descriptor)
cgThings.append(CGDOMJSProxyHandlerDeclarer(handlerThing))
cgThings.append(CGProxyIsProxy(descriptor))
cgThings.append(CGProxyUnwrap(descriptor))
# Set up our Xray callbacks as needed. This needs to come
# after we have our DOMProxyHandler defined.
if descriptor.wantsXrays:
if descriptor.concrete and descriptor.proxy:
if descriptor.needsXrayNamedDeleterHook():
cgThings.append(CGDeleteNamedProperty(descriptor))
elif descriptor.needsXrayResolveHooks():
cgThings.append(CGResolveOwnPropertyViaResolve(descriptor))
cgThings.append(
CGEnumerateOwnPropertiesViaGetOwnPropertyNames(descriptor)
)
if descriptor.wantsXrayExpandoClass:
cgThings.append(CGXrayExpandoJSClass(descriptor))
# Now that we have our ResolveOwnProperty/EnumerateOwnProperties stuff
# done, set up our NativePropertyHooks.
cgThings.append(CGNativePropertyHooks(descriptor, properties))
if descriptor.interface.hasInterfaceObject():
cgThings.append(CGClassConstructor(descriptor, descriptor.interface.ctor()))
cgThings.append(CGInterfaceObjectJSClass(descriptor, properties))
@ -16418,28 +16439,6 @@ class CGDescriptor(CGThing):
cgThings.append(CGDeserializer(descriptor))
if descriptor.proxy:
cgThings.append(
CGGeneric(
fill(
"""
static_assert(std::is_base_of_v<nsISupports, ${nativeType}>,
"We don't support non-nsISupports native classes for "
"proxy-based bindings yet");
""",
nativeType=descriptor.nativeType,
)
)
)
if not descriptor.wrapperCache:
raise TypeError(
"We need a wrappercache to support expandos for proxy-based "
"bindings (" + descriptor.name + ")"
)
handlerThing = CGDOMJSProxyHandler(descriptor)
cgThings.append(CGDOMJSProxyHandlerDeclarer(handlerThing))
cgThings.append(CGProxyIsProxy(descriptor))
cgThings.append(CGProxyUnwrap(descriptor))
cgThings.append(CGDOMJSProxyHandlerDefiner(handlerThing))
cgThings.append(CGDOMProxyJSClass(descriptor))
else:
@ -16458,24 +16457,6 @@ class CGDescriptor(CGThing):
else:
cgThings.append(CGWrapNonWrapperCacheMethod(descriptor, properties))
# Set up our Xray callbacks as needed. This needs to come
# after we have our DOMProxyHandler defined.
if descriptor.wantsXrays:
if descriptor.concrete and descriptor.proxy:
if descriptor.needsXrayNamedDeleterHook():
cgThings.append(CGDeleteNamedProperty(descriptor))
elif descriptor.needsXrayResolveHooks():
cgThings.append(CGResolveOwnPropertyViaResolve(descriptor))
cgThings.append(
CGEnumerateOwnPropertiesViaGetOwnPropertyNames(descriptor)
)
if descriptor.wantsXrayExpandoClass:
cgThings.append(CGXrayExpandoJSClass(descriptor))
# Now that we have our ResolveOwnProperty/EnumerateOwnProperties stuff
# done, set up our NativePropertyHooks.
cgThings.append(CGNativePropertyHooks(descriptor, properties))
# If we're not wrappercached, we don't know how to clear our
# cached values, since we can't get at the JSObject.
if descriptor.wrapperCache:

Просмотреть файл

@ -439,10 +439,6 @@ struct NativePropertyHooks {
// constructors::id::_ID_Count.
constructors::ID mConstructorID;
// The NativePropertyHooks instance for the parent interface (for
// ShimInterfaceInfo).
const NativePropertyHooks* mProtoHooks;
// The JSClass to use for expandos on our Xrays. Can be null, in which case
// Xrays will use a default class of their choice.
const JSClass* mXrayExpandoClass;