Bug 908576 part 6. Expose just a NativePropertyHooks pointer, not the object itself, so we can forward-declare it in bindings headers. r=smaug

This commit is contained in:
Boris Zbarsky 2013-08-23 22:42:41 -04:00
parent 3e11459a52
commit 1be13ddcad
3 changed files with 13 additions and 7 deletions

View File

@ -80,7 +80,7 @@ class CGNativePropertyHooks(CGThing):
def declare(self):
if self.descriptor.workers:
return ""
return "extern const NativePropertyHooks sNativePropertyHooks;\n"
return "extern const NativePropertyHooks* sNativePropertyHooks;\n"
def define(self):
if self.descriptor.workers:
return ""
@ -112,7 +112,7 @@ class CGNativePropertyHooks(CGThing):
else:
prototypeID += "_ID_Count"
parent = self.descriptor.interface.parent
parentHooks = ("&" + toBindingNamespace(parent.identifier.name) + "::sNativePropertyHooks"
parentHooks = (toBindingNamespace(parent.identifier.name) + "::sNativePropertyHooks"
if parent else 'nullptr')
return CGWrapper(CGIndenter(CGList([CGGeneric(resolveOwnProperty),
@ -125,11 +125,13 @@ class CGNativePropertyHooks(CGThing):
CGGeneric(constructorID),
CGGeneric(parentHooks)],
",\n")),
pre="const NativePropertyHooks sNativePropertyHooks = {\n",
post="\n};\n").define()
pre="static const NativePropertyHooks sNativePropertyHooksStruct = {\n",
post=("\n"
"};\n"
"const NativePropertyHooks* sNativePropertyHooks = &sNativePropertyHooksStruct;\n")).define()
def NativePropertyHooks(descriptor):
return "&sWorkerNativePropertyHooks" if descriptor.workers else "&sNativePropertyHooks"
return "&sWorkerNativePropertyHooks" if descriptor.workers else "sNativePropertyHooks"
def DOMClass(descriptor):
protoList = ['prototypes::id::' + proto for proto in descriptor.prototypeChain]
@ -8549,6 +8551,9 @@ class CGForwardDeclarations(CGWrapper):
for d in descriptors:
builder.add(d.nativeType)
# We just about always need NativePropertyHooks
builder.addInMozillaDom("NativePropertyHooks")
for callback in mainCallbacks:
forwardDeclareForType(callback)
for t in getTypesFromCallback(callback):
@ -8691,12 +8696,12 @@ class CGBindingRoot(CGThing):
callbackDescriptors,
['mozilla/dom/BindingDeclarations.h',
'mozilla/ErrorResult.h',
'mozilla/dom/DOMJSClass.h',
'mozilla/dom/DOMJSProxyHandler.h'],
['mozilla/dom/BindingUtils.h',
'mozilla/dom/Nullable.h',
'PrimitiveConversions.h',
'WrapperFactory.h',
'mozilla/dom/DOMJSClass.h',
] + (['WorkerPrivate.h',
'nsThreadUtils.h'] if hasWorkerStuff else [])
+ (['mozilla/Preferences.h'] if requiresPreferences else [])

View File

@ -7,6 +7,7 @@
#define mozilla_dom_workers_dombindinginlines_h__
#include "mozilla/dom/FileReaderSyncBinding.h"
#include "mozilla/dom/JSSlots.h"
#include "mozilla/dom/XMLHttpRequestBinding.h"
#include "mozilla/dom/XMLHttpRequestUploadBinding.h"
#include "mozilla/dom/WorkerLocationBinding.h"

View File

@ -151,5 +151,5 @@ customMethodCalls = {
newBindingProperties = {
# Once the last entry here goes away, we can make the sNativePropertyHooks
# of bindings static.
'nsIDOMEventTarget': 'mozilla::dom::EventTargetBinding::sNativePropertyHooks.mNativeProperties.regular',
'nsIDOMEventTarget': 'mozilla::dom::EventTargetBinding::sNativePropertyHooks->mNativeProperties.regular',
}