Bug 779046. Have saner defaults for the nativeType of a WebIDL bindings. r=peterv

This commit is contained in:
Boris Zbarsky 2012-08-28 13:10:09 -04:00
parent 7919784ad2
commit 0ca95e7360
2 changed files with 29 additions and 44 deletions

View File

@ -10,7 +10,14 @@
#
# Valid fields for all descriptors:
# * nativeType - The native type (concrete class or XPCOM interface) that
# instances of this interface will unwrap to (required).
# instances of this interface will unwrap to. If not
# specified, defaults to "mozilla::dom::InterfaceName" for
# non-worker non-external-or-callback interfaces, to
# "mozilla::dom::workers::InterfaceName" for worker
# non-external interfaces, to 'nsIDOM' followed by the
# interface name for non-worker external-or-callback
# interfaces, and to "JSObject" for worker external-or-callback
# interfaces.
# * headerFile - The file in which the nativeType is declared (defaults
# to an educated guess).
# * castable - Indicates whether the value in the wrapper can be cast to
@ -56,13 +63,10 @@ DOMInterfaces = {
'Blob': [
{
'nativeType': 'nsIDOMBlob',
'headerFile': 'nsIDOMFile.h',
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
}],
'CanvasRenderingContext2D': [
@ -98,29 +102,20 @@ DOMInterfaces = {
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
}],
'Event': [
{
'nativeType': 'nsIDOMEvent',
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
}],
'EventListener': [
{
'nativeType': 'nsIDOMEventListener',
'prefable': True
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h'
}],
'EventTarget': [
@ -132,19 +127,15 @@ DOMInterfaces = {
},
{
'workers': True,
'nativeType': 'mozilla::dom::workers::EventTarget',
'headerFile': 'mozilla/dom/workers/bindings/EventTarget.h',
'concrete': False
}],
'FormData': [
{
'nativeType': 'nsIDOMFormData',
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
}],
'IID': [
@ -154,8 +145,6 @@ DOMInterfaces = {
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
}],
'InputStream': [
@ -165,8 +154,6 @@ DOMInterfaces = {
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
}],
'MozChannel': [
@ -176,8 +163,6 @@ DOMInterfaces = {
},
{
'workers': True,
'nativeType': 'JSObject',
'headerFile': 'jsapi.h',
}],
'Performance': {
@ -219,7 +204,6 @@ DOMInterfaces = {
},
{
'workers': True,
'nativeType': 'mozilla::dom::workers::XMLHttpRequest',
'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequest.h',
}],
@ -233,7 +217,6 @@ DOMInterfaces = {
{
'workers': True,
'concrete': False,
'nativeType': 'mozilla::dom::workers::XMLHttpRequestEventTarget',
'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequestEventTarget.h'
}],
@ -245,7 +228,6 @@ DOMInterfaces = {
},
{
'workers': True,
'nativeType': 'mozilla::dom::workers::XMLHttpRequestUpload',
'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequestUpload.h'
}],
@ -254,7 +236,6 @@ DOMInterfaces = {
####################################
'TestInterface' : {
'nativeType': 'mozilla::dom::TestInterface',
'headerFile': 'TestBindingHeader.h',
'register': False,
'resultNotAddRefed': [ 'receiveWeakSelf', 'receiveWeakNullableSelf',
@ -272,7 +253,6 @@ DOMInterfaces = {
},
'TestNonCastableInterface' : {
'nativeType': 'mozilla::dom::TestNonCastableInterface',
'headerFile': 'TestBindingHeader.h',
'register': False,
'castable': False
@ -285,7 +265,6 @@ DOMInterfaces = {
},
'TestNonWrapperCacheInterface' : {
'nativeType': 'mozilla::dom::TestNonWrapperCacheInterface',
'headerFile': 'TestBindingHeader.h',
'register': False,
'wrapperCache': False
@ -298,7 +277,6 @@ DOMInterfaces = {
},
'IndirectlyImplementedInterface': {
'nativeType': 'mozilla::dom::IndirectlyImplementedInterface',
'headerFile': 'TestBindingHeader.h',
'register': False,
'castable': False,
@ -306,52 +284,44 @@ DOMInterfaces = {
},
'OnlyForUseInConstructor' : {
'nativeType': 'mozilla::dom::OnlyForUseInConstructor',
'headerFile': 'TestBindingHeader.h',
'register': False
},
'TestIndexedGetterInterface' : {
'nativeType': 'mozilla::dom::TestIndexedGetterInterface',
'headerFile': 'TestBindingHeader.h',
'register': False,
'infallible': [ 'length' ]
},
'TestNamedGetterInterface' : {
'nativeType': 'mozilla::dom::TestNamedGetterInterface',
'headerFile': 'TestBindingHeader.h',
'register': False
},
'TestIndexedAndNamedGetterInterface' : {
'nativeType': 'mozilla::dom::TestIndexedAndNamedGetterInterface',
'headerFile': 'TestBindingHeader.h',
'register': False,
'infallible': [ 'length' ]
},
'TestIndexedSetterInterface' : {
'nativeType': 'mozilla::dom::TestIndexedSetterInterface',
'headerFile': 'TestBindingHeader.h',
'register': False
},
'TestNamedSetterInterface' : {
'nativeType': 'mozilla::dom::TestNamedSetterInterface',
'headerFile': 'TestBindingHeader.h',
'register': False
},
'TestIndexedAndNamedSetterInterface' : {
'nativeType': 'mozilla::dom::TestIndexedAndNamedSetterInterface',
'headerFile': 'TestBindingHeader.h',
'register': False
},
'TestIndexedAndNamedGetterAndSetterInterface' : {
'nativeType': 'mozilla::dom::TestIndexedAndNamedGetterAndSetterInterface',
'headerFile': 'TestBindingHeader.h',
'register': False,
'infallible': [ 'length', '__stringifier' ],
@ -361,12 +331,11 @@ DOMInterfaces = {
# These are temporary, until they've been converted to use new DOM bindings
def addExternalIface(iface, nativeType=None, headerFile=None):
if nativeType is None:
nativeType = 'nsIDOM' + iface
domInterface = {
'nativeType': nativeType,
'concrete': False
}
if not nativeType is None:
domInterface['nativeType'] = nativeType
if not headerFile is None:
domInterface['headerFile'] = headerFile
DOMInterfaces[iface] = domInterface

View File

@ -127,11 +127,27 @@ class Descriptor(DescriptorProvider):
self.interface = interface
# Read the desc, and fill in the relevant defaults.
self.nativeType = desc['nativeType']
ifaceName = self.interface.identifier.name
if self.interface.isExternal() or self.interface.isCallback():
if self.workers:
nativeTypeDefault = "JSObject"
else:
nativeTypeDefault = "nsIDOM" + ifaceName
else:
if self.workers:
nativeTypeDefault = "mozilla::dom::workers::" + ifaceName
else:
nativeTypeDefault = "mozilla::dom::" + ifaceName
self.nativeType = desc.get('nativeType', nativeTypeDefault)
self.hasInstanceInterface = desc.get('hasInstanceInterface', None)
headerDefault = self.nativeType
headerDefault = headerDefault.replace("::", "/") + ".h"
# Do something sane for JSObject
if self.nativeType == "JSObject":
headerDefault = "jsapi.h"
else:
headerDefault = self.nativeType
headerDefault = headerDefault.replace("::", "/") + ".h"
self.headerFile = desc.get('headerFile', headerDefault)
if self.interface.isCallback() or self.interface.isExternal():