mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Remove abstract_self.
This commit is contained in:
parent
76783b029e
commit
7daa97c7e5
19 changed files with 483 additions and 610 deletions
|
@ -9,8 +9,6 @@
|
|||
# The configuration table maps each interface name to a |descriptor|.
|
||||
#
|
||||
# Valid fields for all descriptors:
|
||||
# * needsAbstract: a list of members that require a JS<>-wrapped version of
|
||||
# self to be passed to the native code.
|
||||
# * createGlobal: True for global objects.
|
||||
# * outerObjectHook: string to use in place of default value for outerObject and thisObject
|
||||
# JS class hooks
|
||||
|
@ -26,123 +24,46 @@ DOMInterfaces = {
|
|||
'ClientRect': {},
|
||||
'ClientRectList': {},
|
||||
'Console': {},
|
||||
'Document': {
|
||||
'needsAbstract': [
|
||||
'adoptNode',
|
||||
'anchors',
|
||||
'applets',
|
||||
'body',
|
||||
'children',
|
||||
'createComment',
|
||||
'createDocumentFragment',
|
||||
'createElement',
|
||||
'createElementNS',
|
||||
'createProcessingInstruction',
|
||||
'createTextNode',
|
||||
'embeds',
|
||||
'forms',
|
||||
'getElementsByClassName',
|
||||
'getElementsByTagName',
|
||||
'getElementsByTagNameNS',
|
||||
'images',
|
||||
'importNode',
|
||||
'links',
|
||||
'location',
|
||||
'plugins',
|
||||
'scripts',
|
||||
'title',
|
||||
],
|
||||
},
|
||||
'Document': {},
|
||||
'DOMException': {},
|
||||
'DOMImplementation': {},
|
||||
'DOMParser': {},
|
||||
'Element': {
|
||||
'needsAbstract': [
|
||||
'attributes',
|
||||
'children',
|
||||
'className',
|
||||
'getAttribute',
|
||||
'getAttributeNS',
|
||||
'getBoundingClientRect',
|
||||
'getClientRects',
|
||||
'getElementsByClassName',
|
||||
'getElementsByTagName',
|
||||
'getElementsByTagNameNS',
|
||||
'hasAttribute',
|
||||
'hasAttributeNS',
|
||||
'id',
|
||||
'innerHTML',
|
||||
'outerHTML',
|
||||
'removeAttribute',
|
||||
'removeAttributeNS',
|
||||
'setAttribute',
|
||||
'setAttributeNS',
|
||||
]
|
||||
},
|
||||
'Element': {},
|
||||
'Event': {},
|
||||
'EventListener': {
|
||||
'nativeType': 'EventListenerBinding::EventListener',
|
||||
},
|
||||
'EventTarget': {
|
||||
'needsAbstract': ['dispatchEvent']
|
||||
},
|
||||
'EventTarget': {},
|
||||
'FormData': {},
|
||||
'HTMLCollection': {},
|
||||
'Location': {},
|
||||
'MouseEvent': {},
|
||||
'Navigator': {},
|
||||
'Node': {
|
||||
'needsAbstract': [
|
||||
'appendChild',
|
||||
'childNodes',
|
||||
'cloneNode',
|
||||
'compareDocumentPosition',
|
||||
'contains',
|
||||
'insertBefore',
|
||||
'isEqualNode',
|
||||
'namespaceURI',
|
||||
'nodeName',
|
||||
'nodeValue',
|
||||
'normalize',
|
||||
'removeChild',
|
||||
'replaceChild',
|
||||
'textContent',
|
||||
]
|
||||
},
|
||||
|
||||
'Node': {},
|
||||
'NodeList': {},
|
||||
|
||||
'UIEvent': {},
|
||||
'ValidityState': {},
|
||||
'Window': {
|
||||
'createGlobal': True,
|
||||
'outerObjectHook': 'Some(bindings::utils::outerize_global)',
|
||||
'needsAbstract': [
|
||||
'console',
|
||||
'location',
|
||||
'navigator',
|
||||
'self',
|
||||
'window',
|
||||
],
|
||||
},
|
||||
'XMLHttpRequest': {},
|
||||
'XMLHttpRequestEventTarget': {},
|
||||
'XMLHttpRequestUpload': {},
|
||||
|
||||
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
|
||||
'TestBinding': {},
|
||||
|
||||
}
|
||||
|
||||
# FIXME: This should be renamed: https://github.com/mozilla/servo/issues/1625
|
||||
def addHTMLElement(element, concrete=None, needsAbstract=[]):
|
||||
def addHTMLElement(element):
|
||||
DOMInterfaces[element] = {
|
||||
'nativeType': 'JS<%s>' % element,
|
||||
'concreteType': concrete if concrete else element,
|
||||
'needsAbstract': needsAbstract
|
||||
}
|
||||
|
||||
addHTMLElement('Comment')
|
||||
addHTMLElement('DocumentFragment', concrete='DocumentFragment', needsAbstract=['children'])
|
||||
addHTMLElement('DocumentFragment')
|
||||
addHTMLElement('DocumentType')
|
||||
addHTMLElement('Text')
|
||||
addHTMLElement('ProcessingInstruction')
|
||||
|
@ -158,12 +79,12 @@ addHTMLElement('HTMLBRElement')
|
|||
addHTMLElement('HTMLCanvasElement')
|
||||
addHTMLElement('HTMLDataElement')
|
||||
addHTMLElement('HTMLDivElement')
|
||||
addHTMLElement('HTMLDataListElement', needsAbstract=['options'])
|
||||
addHTMLElement('HTMLDataListElement')
|
||||
addHTMLElement('HTMLDirectoryElement')
|
||||
addHTMLElement('HTMLDListElement')
|
||||
addHTMLElement('HTMLElement')
|
||||
addHTMLElement('HTMLEmbedElement')
|
||||
addHTMLElement('HTMLFieldSetElement', needsAbstract=['elements'])
|
||||
addHTMLElement('HTMLFieldSetElement')
|
||||
addHTMLElement('HTMLFontElement')
|
||||
addHTMLElement('HTMLFormElement')
|
||||
addHTMLElement('HTMLFrameElement')
|
||||
|
@ -172,8 +93,8 @@ addHTMLElement('HTMLHeadElement')
|
|||
addHTMLElement('HTMLHeadingElement')
|
||||
addHTMLElement('HTMLHtmlElement')
|
||||
addHTMLElement('HTMLHRElement')
|
||||
addHTMLElement('HTMLIFrameElement', needsAbstract=['sandbox'])
|
||||
addHTMLElement('HTMLImageElement', needsAbstract=['alt', 'src', 'useMap', 'isMap', 'width', 'height', 'name', 'align', 'hspace', 'vspace', 'longDesc', 'border'])
|
||||
addHTMLElement('HTMLIFrameElement')
|
||||
addHTMLElement('HTMLImageElement')
|
||||
addHTMLElement('HTMLInputElement')
|
||||
addHTMLElement('HTMLLabelElement')
|
||||
addHTMLElement('HTMLLegendElement')
|
||||
|
@ -195,7 +116,7 @@ addHTMLElement('HTMLParamElement')
|
|||
addHTMLElement('HTMLPreElement')
|
||||
addHTMLElement('HTMLProgressElement')
|
||||
addHTMLElement('HTMLQuoteElement')
|
||||
addHTMLElement('HTMLScriptElement', needsAbstract=['src'])
|
||||
addHTMLElement('HTMLScriptElement')
|
||||
addHTMLElement('HTMLSelectElement')
|
||||
addHTMLElement('HTMLSourceElement')
|
||||
addHTMLElement('HTMLSpanElement')
|
||||
|
|
|
@ -2494,12 +2494,6 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
|||
nativeName = MakeNativeName(name)
|
||||
extraPre = ''
|
||||
argsPre = []
|
||||
if name in self.descriptor.needsAbstract:
|
||||
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
|
||||
extraPre = """ let mut abstract_this = %s::from_raw(this);
|
||||
let abstract_this = abstract_this.root(&roots);
|
||||
""" % abstractName
|
||||
argsPre = ['&mut abstract_this.root_ref()']
|
||||
return CGWrapper(CGMethodCall(argsPre, nativeName, self.method.isStatic(),
|
||||
self.descriptor, self.method),
|
||||
pre=extraPre +
|
||||
|
@ -2552,12 +2546,6 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
|||
infallible = ('infallible' in
|
||||
self.descriptor.getExtendedAttributes(self.attr,
|
||||
getter=True))
|
||||
if name in self.descriptor.needsAbstract:
|
||||
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
|
||||
extraPre = """ let mut abstract_this = %s::from_raw(this);
|
||||
let abstract_this = abstract_this.root(&roots);
|
||||
""" % abstractName
|
||||
argsPre = ['&mut abstract_this.root_ref()']
|
||||
if self.attr.type.nullable() or not infallible:
|
||||
nativeName = "Get" + nativeName
|
||||
return CGWrapper(CGIndenter(CGGetterCall(argsPre, self.attr.type, nativeName,
|
||||
|
@ -2614,12 +2602,6 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
|||
nativeName = "Set" + MakeNativeName(name)
|
||||
argsPre = []
|
||||
extraPre = ''
|
||||
if name in self.descriptor.needsAbstract:
|
||||
abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
|
||||
extraPre = """ let mut abstract_this = %s::from_raw(this);
|
||||
let abstract_this = abstract_this.root(&roots);
|
||||
""" % abstractName
|
||||
argsPre = ['&mut abstract_this.root_ref()']
|
||||
return CGWrapper(CGIndenter(CGSetterCall(argsPre, self.attr.type, nativeName,
|
||||
self.descriptor, self.attr)),
|
||||
pre=extraPre +
|
||||
|
|
|
@ -136,7 +136,6 @@ class Descriptor(DescriptorProvider):
|
|||
self.returnType = "Unrooted<%s>" % ifaceName
|
||||
self.nativeType = desc.get('nativeType', nativeTypeDefault)
|
||||
self.concreteType = desc.get('concreteType', ifaceName)
|
||||
self.needsAbstract = desc.get('needsAbstract', [])
|
||||
self.createGlobal = desc.get('createGlobal', False)
|
||||
self.register = desc.get('register', True)
|
||||
self.outerObjectHook = desc.get('outerObjectHook', 'None')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue