Back out Bug 827486 for PGO bustage. CLOSED TREE

This commit is contained in:
Kyle Huey
2013-03-18 13:00:00 -07:00
parent c0381e71b8
commit 141e90d173
8 changed files with 47 additions and 708 deletions

View File

@@ -1114,24 +1114,6 @@ DOMInterfaces = {
'register': False, 'register': False,
}, },
'TestJSImplInterface' : {
# Keep this in sync with TestExampleInterface
'headerFile': 'TestJSImplGenBinding.h',
'register': False,
'resultNotAddRefed': [ 'receiveWeakSelf', 'receiveWeakNullableSelf',
'receiveWeakOther', 'receiveWeakNullableOther',
'receiveWeakExternal', 'receiveWeakNullableExternal',
'ReceiveWeakCallbackInterface',
'ReceiveWeakNullableCallbackInterface',
'receiveWeakCastableObjectSequence',
'receiveWeakNullableCastableObjectSequence',
'receiveWeakCastableObjectNullableSequence',
'receiveWeakNullableCastableObjectNullableSequence' ],
'binaryNames': { 'methodRenamedFrom': 'methodRenamedTo',
'attributeGetterRenamedFrom': 'attributeGetterRenamedTo',
'attributeRenamedFrom': 'attributeRenamedTo' }
},
'TestExternalInterface' : { 'TestExternalInterface' : {
'nativeType': 'mozilla::dom::TestExternalInterface', 'nativeType': 'mozilla::dom::TestExternalInterface',
'headerFile': 'TestBindingHeader.h', 'headerFile': 'TestBindingHeader.h',

View File

@@ -10,7 +10,7 @@ import re
import string import string
from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, Descriptor from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback
AUTOGENERATED_WARNING_COMMENT = \ AUTOGENERATED_WARNING_COMMENT = \
"/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n" "/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
@@ -476,9 +476,8 @@ class CGHeaders(CGWrapper):
Generates the appropriate include statements. Generates the appropriate include statements.
""" """
def __init__(self, descriptors, dictionaries, callbacks, def __init__(self, descriptors, dictionaries, callbacks,
callbackDescriptors, callbackDescriptors, declareIncludes, defineIncludes, child,
declareIncludes, defineIncludes, child, config=None):
config=None, anyJSImplemented=False):
""" """
Builds a set of includes to cover |descriptors|. Builds a set of includes to cover |descriptors|.
@@ -587,7 +586,7 @@ class CGHeaders(CGWrapper):
# And we need BindingUtils.h so we can wrap "this" objects # And we need BindingUtils.h so we can wrap "this" objects
declareIncludes.add("mozilla/dom/BindingUtils.h") declareIncludes.add("mozilla/dom/BindingUtils.h")
if len(callbackDescriptors) != 0 or anyJSImplemented: if len(callbackDescriptors) != 0:
# We need CallbackInterface to serve as our parent class # We need CallbackInterface to serve as our parent class
declareIncludes.add("mozilla/dom/CallbackInterface.h") declareIncludes.add("mozilla/dom/CallbackInterface.h")
# And we need BindingUtils.h so we can wrap "this" objects # And we need BindingUtils.h so we can wrap "this" objects
@@ -7076,8 +7075,7 @@ class CGBindingRoot(CGThing):
workers=True) workers=True)
callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile, callbackDescriptors = config.getDescriptors(webIDLFile=webIDLFile,
isCallback=True) isCallback=True)
jsImplemented = config.getDescriptors(webIDLFile=webIDLFile,
isJSImplemented=True)
forwardDeclares = [CGClassForwardDeclare('XPCWrappedNativeScope')] forwardDeclares = [CGClassForwardDeclare('XPCWrappedNativeScope')]
descriptorsForForwardDeclaration = list(descriptors) descriptorsForForwardDeclaration = list(descriptors)
@@ -7231,11 +7229,6 @@ class CGBindingRoot(CGThing):
# Do codegen for all the callback interfaces # Do codegen for all the callback interfaces
cgthings.extend([CGCallbackInterface(x) for x in callbackDescriptors]) cgthings.extend([CGCallbackInterface(x) for x in callbackDescriptors])
# Do codegen for JS implemented classes
for x in jsImplemented:
cgthings.append(CGCallbackInterface(x))
cgthings.append(CGJSImplClass(x))
# And make sure we have the right number of newlines at the end # And make sure we have the right number of newlines at the end
curr = CGWrapper(CGList(cgthings, "\n\n"), post="\n\n") curr = CGWrapper(CGList(cgthings, "\n\n"), post="\n\n")
@@ -7274,8 +7267,7 @@ class CGBindingRoot(CGThing):
'nsDOMQS.h' 'nsDOMQS.h'
], ],
curr, curr,
config, config)
anyJSImplemented = len(jsImplemented) != 0)
# Add include guards. # Add include guards.
curr = CGIncludeGuard(prefix, curr) curr = CGIncludeGuard(prefix, curr)
@@ -7629,7 +7621,7 @@ class CGNativeMember(ClassMethod):
class CGExampleMethod(CGNativeMember): class CGExampleMethod(CGNativeMember):
def __init__(self, descriptor, method, signature, isConstructor, breakAfter=True): def __init__(self, descriptor, method, signature, breakAfter=True):
CGNativeMember.__init__(self, descriptor, method, CGNativeMember.__init__(self, descriptor, method,
CGSpecializedMethod.makeNativeName(descriptor, CGSpecializedMethod.makeNativeName(descriptor,
method), method),
@@ -7663,45 +7655,38 @@ class CGExampleSetter(CGNativeMember):
def define(self, cgClass): def define(self, cgClass):
return '' return ''
class CGBindingImplClass(CGClass): class CGExampleClass(CGClass):
""" """
Common codegen for generating a C++ implementation of a WebIDL interface Codegen for the actual example class implemenation for this descriptor
"""
def __init__(self, descriptor, cgMethod, cgGetter, cgSetter):
"""
cgMethod, cgGetter and cgSetter are classes used to codegen methods,
getters and setters.
""" """
def __init__(self, descriptor):
self.descriptor = descriptor self.descriptor = descriptor
self._deps = descriptor.interface.getDeps()
iface = descriptor.interface iface = descriptor.interface
self.methodDecls = [] methodDecls = []
def appendMethod(m, isConstructor=False): def appendMethod(m):
sigs = m.signatures() sigs = m.signatures()
for s in sigs[:-1]: for s in sigs[:-1]:
# Don't put an empty line after overloads, until we # Don't put an empty line after overloads, until we
# get to the last one. # get to the last one.
self.methodDecls.append(cgMethod(descriptor, m, s, methodDecls.append(CGExampleMethod(descriptor, m, s,
isConstructor,
breakAfter=False)) breakAfter=False))
self.methodDecls.append(cgMethod(descriptor, m, sigs[-1], methodDecls.append(CGExampleMethod(descriptor, m, sigs[-1]))
isConstructor))
if iface.ctor(): if iface.ctor():
appendMethod(iface.ctor(), isConstructor=True) appendMethod(iface.ctor())
for n in iface.namedConstructors: for n in iface.namedConstructors:
appendMethod(n, isConstructor=True) appendMethod(n)
for m in iface.members: for m in iface.members:
if m.isMethod(): if m.isMethod():
if m.isIdentifierLess(): if m.isIdentifierLess():
continue continue
appendMethod(m) appendMethod(m)
elif m.isAttr(): elif m.isAttr():
self.methodDecls.append(cgGetter(descriptor, m)) methodDecls.append(CGExampleGetter(descriptor, m))
if not m.readonly: if not m.readonly:
self.methodDecls.append(cgSetter(descriptor, m)) methodDecls.append(CGExampleSetter(descriptor, m))
# Now do the special operations # Now do the special operations
def appendSpecialOperation(name, op): def appendSpecialOperation(name, op):
@@ -7734,7 +7719,7 @@ class CGBindingImplClass(CGClass):
else: else:
# We already added this method # We already added this method
return return
self.methodDecls.append( methodDecls.append(
CGNativeMember(descriptor, op, CGNativeMember(descriptor, op,
name, name,
(returnType, args), (returnType, args),
@@ -7747,7 +7732,7 @@ class CGBindingImplClass(CGClass):
# If we support indexed properties, then we need a Length() # If we support indexed properties, then we need a Length()
# method so we know which indices are supported. # method so we know which indices are supported.
if descriptor.supportsIndexedProperties(): if descriptor.supportsIndexedProperties():
self.methodDecls.append( methodDecls.append(
CGNativeMember(descriptor, FakeMember(), CGNativeMember(descriptor, FakeMember(),
"Length", "Length",
(BuiltinTypes[IDLBuiltinType.Types.unsigned_long], (BuiltinTypes[IDLBuiltinType.Types.unsigned_long],
@@ -7756,7 +7741,7 @@ class CGBindingImplClass(CGClass):
# And if we support named properties we need to be able to # And if we support named properties we need to be able to
# enumerate the supported names. # enumerate the supported names.
if descriptor.supportsNamedProperties(): if descriptor.supportsNamedProperties():
self.methodDecls.append( methodDecls.append(
CGNativeMember( CGNativeMember(
descriptor, FakeMember(), descriptor, FakeMember(),
"GetSupportedNames", "GetSupportedNames",
@@ -7767,41 +7752,18 @@ class CGBindingImplClass(CGClass):
wrapArgs = [Argument('JSContext*', 'aCx'), wrapArgs = [Argument('JSContext*', 'aCx'),
Argument('JSObject*', 'aScope')] Argument('JSObject*', 'aScope')]
self.methodDecls.insert(0, methodDecls.insert(0,
ClassMethod("WrapObject", "JSObject*", ClassMethod("WrapObject", "JSObject*",
wrapArgs, virtual=descriptor.wrapperCache, wrapArgs, virtual=descriptor.wrapperCache,
breakAfterReturnDecl=" ", breakAfterReturnDecl=" "))
body=self.getWrapObjectBody())) getParentObjectReturnType = (
self.methodDecls.insert(0, "// TODO: return something sensible here, and change the return type\n"
"%s*" % descriptor.name)
methodDecls.insert(0,
ClassMethod("GetParentObject", ClassMethod("GetParentObject",
self.getGetParentObjectReturnType(), getParentObjectReturnType,
[], const=True, [], const=True,
breakAfterReturnDecl=" ", breakAfterReturnDecl=" "))
body=self.getGetParentObjectBody()))
# Invoke CGClass.__init__ in any subclasses afterwards to do the actual codegen.
def getWrapObjectBody(self):
return None
def getGetParentObjectReturnType(self):
return ("// TODO: return something sensible here, and change the return type\n"
"%s*" % self.descriptor.name)
def getGetParentObjectBody(self):
return None
def deps(self):
return self._deps
class CGExampleClass(CGBindingImplClass):
"""
Codegen for the actual example class implementation for this descriptor
"""
def __init__(self, descriptor):
CGBindingImplClass.__init__(self, descriptor, CGExampleMethod, CGExampleGetter, CGExampleSetter)
extradeclarations=( extradeclarations=(
"public:\n" "public:\n"
" NS_DECL_CYCLE_COLLECTING_ISUPPORTS\n" " NS_DECL_CYCLE_COLLECTING_ISUPPORTS\n"
@@ -7814,7 +7776,7 @@ class CGExampleClass(CGBindingImplClass):
constructors=[ClassConstructor([], constructors=[ClassConstructor([],
visibility="public")], visibility="public")],
destructor=ClassDestructor(visibility="public"), destructor=ClassDestructor(visibility="public"),
methods=self.methodDecls, methods=methodDecls,
decorators="MOZ_FINAL", decorators="MOZ_FINAL",
extradeclarations=extradeclarations) extradeclarations=extradeclarations)
@@ -7907,158 +7869,6 @@ class CGExampleRoot(CGThing):
def define(self): def define(self):
return self.root.define() return self.root.define()
def jsImplName(name):
return name + "JSImpl"
class CGJSImplMethod(CGNativeMember):
def __init__(self, descriptor, method, signature, isConstructor, breakAfter=True):
CGNativeMember.__init__(self, descriptor, method,
CGSpecializedMethod.makeNativeName(descriptor,
method),
signature,
descriptor.getExtendedAttributes(method),
breakAfter=breakAfter,
variadicIsSequence=True)
self.signature = signature
if isConstructor:
self.body = self.getConstructorImpl()
else:
self.body = self.getImpl()
def getImpl(self):
callbackArgs = [arg.name for arg in self.getArgs(self.signature[0], self.signature[1])]
return 'return mImpl->%s(%s);' % (self.name, ", ".join(callbackArgs))
def getConstructorImpl(self):
assert self.descriptor.interface.isJSImplemented()
if self.name != 'Constructor':
raise TypeError("Named constructors are not supported for JS implemented WebIDL. See bug 851287.")
if len(self.signature[1]) != 0:
raise TypeError("Constructors with arguments are unsupported. See bug 851178.")
return string.Template(
""" // Get the window to use as a parent.
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(global.Get());
if (!window) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
// Get the JS implementation for the WebIDL interface.
nsCOMPtr<nsISupports> implISupports = do_CreateInstance("${contractId}");
MOZ_ASSERT(implISupports, "Failed to get JS implementation instance from contract ID.");
if (!implISupports) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsIXPConnectWrappedJS> implWrapped = do_QueryInterface(implISupports);
MOZ_ASSERT(implWrapped, "Failed to get wrapped JS from XPCOM component.");
if (!implWrapped) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
JSObject* jsImplObj;
if (NS_FAILED(implWrapped->GetJSObject(&jsImplObj))) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
// Construct the callback interface object.
bool initOk;
nsRefPtr<${callbackClass}> cbImpl = new ${callbackClass}(cx, nullptr, jsImplObj, &initOk);
if (!initOk) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
// Build the actual implementation.
nsRefPtr<${implClass}> impl = new ${implClass}(cbImpl, window);
return impl.forget();""").substitute({"implClass" : self.descriptor.name,
"callbackClass" : jsImplName(self.descriptor.name),
"contractId" : self.descriptor.interface.getJSImplementation()
})
# We're always fallible
def callbackGetterName(attr):
return "Get" + MakeNativeName(attr.identifier.name)
def callbackSetterName(attr):
return "Set" + MakeNativeName(attr.identifier.name)
class CGJSImplGetter(CGNativeMember):
def __init__(self, descriptor, attr):
CGNativeMember.__init__(self, descriptor, attr,
CGSpecializedGetter.makeNativeName(descriptor,
attr),
(attr.type, []),
descriptor.getExtendedAttributes(attr,
getter=True))
self.body = self.getImpl()
def getImpl(self):
callbackArgs = [arg.name for arg in self.getArgs(self.member.type, [])]
return 'return mImpl->%s(%s);' % (callbackGetterName(self.member), ", ".join(callbackArgs))
class CGJSImplSetter(CGNativeMember):
def __init__(self, descriptor, attr):
CGNativeMember.__init__(self, descriptor, attr,
CGSpecializedSetter.makeNativeName(descriptor,
attr),
(BuiltinTypes[IDLBuiltinType.Types.void],
[FakeArgument(attr.type, attr)]),
descriptor.getExtendedAttributes(attr,
setter=True))
self.body = self.getImpl()
def getImpl(self):
callbackArgs = [arg.name for arg in self.getArgs(BuiltinTypes[IDLBuiltinType.Types.void],
[FakeArgument(self.member.type, self.member)])]
return 'mImpl->%s(%s);' % (callbackSetterName(self.member), ", ".join(callbackArgs))
class CGJSImplClass(CGBindingImplClass):
def __init__(self, descriptor):
CGBindingImplClass.__init__(self, descriptor, CGJSImplMethod, CGJSImplGetter, CGJSImplSetter)
extradeclarations=(
"public:\n"
" NS_DECL_CYCLE_COLLECTING_ISUPPORTS\n"
" NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(%s)\n"
"\n"
"private:\n"
" nsRefPtr<%s> mImpl;\n"
" nsCOMPtr<nsISupports> mParent;\n"
"\n" % (descriptor.name, jsImplName(descriptor.name)))
extradefinitions= string.Template(
"NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(${ifaceName}, mImpl, mParent)\n"
"NS_IMPL_CYCLE_COLLECTING_ADDREF(${ifaceName})\n"
"NS_IMPL_CYCLE_COLLECTING_RELEASE(${ifaceName})\n"
"NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(${ifaceName})\n"
" NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY\n"
" NS_INTERFACE_MAP_ENTRY(nsISupports)\n"
"NS_INTERFACE_MAP_END\n").substitute({ "ifaceName": self.descriptor.name })
CGClass.__init__(self, descriptor.name,
bases=[ClassBase("nsISupports"),
ClassBase("nsWrapperCache")],
constructors=[ClassConstructor([Argument(jsImplName(descriptor.name) + "*", "aImpl"),
Argument("nsISupports*", "aParent")],
visibility="public",
baseConstructors=["mImpl(aImpl)",
"mParent(aParent)"],
body="SetIsDOMBinding();")],
methods=self.methodDecls,
decorators="MOZ_FINAL",
extradeclarations=extradeclarations,
extradefinitions=extradefinitions)
def getWrapObjectBody(self):
return "return %sBinding::Wrap(aCx, aScope, this);" % self.descriptor.name
def getGetParentObjectReturnType(self):
return "nsISupports*"
def getGetParentObjectBody(self):
return "return mParent;"
class CGCallback(CGClass): class CGCallback(CGClass):
def __init__(self, idlObject, descriptorProvider, baseName, methods, def __init__(self, idlObject, descriptorProvider, baseName, methods,
getters=[], setters=[]): getters=[], setters=[]):
@@ -8067,8 +7877,6 @@ class CGCallback(CGClass):
name = idlObject.identifier.name name = idlObject.identifier.name
if descriptorProvider.workers: if descriptorProvider.workers:
name += "Workers" name += "Workers"
if isinstance(descriptorProvider, Descriptor) and descriptorProvider.interface.isJSImplemented():
name = jsImplName(name)
# For our public methods that needThisHandling we want most of the # For our public methods that needThisHandling we want most of the
# same args and the same return type as what CallbackMember # same args and the same return type as what CallbackMember
# generates. So we want to take advantage of all its # generates. So we want to take advantage of all its
@@ -8231,7 +8039,7 @@ class CallbackMember(CGNativeMember):
# will handle generating public versions that handle the "this" stuff. # will handle generating public versions that handle the "this" stuff.
visibility = "private" if needThisHandling else "public" visibility = "private" if needThisHandling else "public"
# We don't care, for callback codegen, whether our original member was # We don't care, for callback codegen, whether our original member was
# a method or attribute or whatnot. Just always pass FakeMember() # a method or attribure or whatnot. Just always pass FakeMember()
# here. # here.
CGNativeMember.__init__(self, descriptorProvider, FakeMember(), CGNativeMember.__init__(self, descriptorProvider, FakeMember(),
name, (self.retvalType, args), name, (self.retvalType, args),
@@ -8501,7 +8309,8 @@ class CallbackGetter(CallbackMember):
self.attrName = attr.identifier.name self.attrName = attr.identifier.name
CallbackMember.__init__(self, CallbackMember.__init__(self,
(attr.type, []), (attr.type, []),
callbackGetterName(attr), # We're always fallible
"Get" + MakeNativeName(attr.identifier.name),
descriptor, descriptor,
needThisHandling=False) needThisHandling=False)
@@ -8526,7 +8335,7 @@ class CallbackSetter(CallbackMember):
CallbackMember.__init__(self, CallbackMember.__init__(self,
(BuiltinTypes[IDLBuiltinType.Types.void], (BuiltinTypes[IDLBuiltinType.Types.void],
[FakeArgument(attr.type, attr)]), [FakeArgument(attr.type, attr)]),
callbackSetterName(attr), "Set" + MakeNativeName(attr.identifier.name),
descriptor, descriptor,
needThisHandling=False) needThisHandling=False)

View File

@@ -113,8 +113,6 @@ class Configuration:
getter = lambda x: x.interface.isCallback() getter = lambda x: x.interface.isCallback()
elif key == 'isExternal': elif key == 'isExternal':
getter = lambda x: x.interface.isExternal() getter = lambda x: x.interface.isExternal()
elif key == 'isJSImplemented':
getter = lambda x: x.interface.isJSImplemented()
else: else:
getter = lambda x: getattr(x, key) getter = lambda x: getattr(x, key)
curr = filter(lambda x: getter(x) == val, curr) curr = filter(lambda x: getter(x) == val, curr)
@@ -215,7 +213,7 @@ class Descriptor(DescriptorProvider):
# Do something sane for JSObject # Do something sane for JSObject
if self.nativeType == "JSObject": if self.nativeType == "JSObject":
headerDefault = "jsapi.h" headerDefault = "jsapi.h"
elif self.interface.isCallback() or self.interface.isJSImplemented(): elif self.interface.isCallback():
# A copy of CGHeaders.getDeclarationFilename; we can't # A copy of CGHeaders.getDeclarationFilename; we can't
# import it here, sadly. # import it here, sadly.
# Use our local version of the header, not the exported one, so that # Use our local version of the header, not the exported one, so that
@@ -378,9 +376,6 @@ class Descriptor(DescriptorProvider):
else: else:
add('all', [config], attribute) add('all', [config], attribute)
if self.interface.isJSImplemented():
addExtendedAttribute('implicitJSContext', ['constructor'])
else:
for attribute in ['implicitJSContext', 'resultNotAddRefed']: for attribute in ['implicitJSContext', 'resultNotAddRefed']:
addExtendedAttribute(attribute, desc.get(attribute, {})) addExtendedAttribute(attribute, desc.get(attribute, {}))
@@ -425,9 +420,9 @@ class Descriptor(DescriptorProvider):
attrs.append("infallible") attrs.append("infallible")
name = member.identifier.name name = member.identifier.name
throws = self.interface.isJSImplemented() or member.getExtendedAttribute("Throws")
if member.isMethod(): if member.isMethod():
attrs = self.extendedAttributes['all'].get(name, []) attrs = self.extendedAttributes['all'].get(name, [])
throws = member.getExtendedAttribute("Throws")
maybeAppendInfallibleToAttrs(attrs, throws) maybeAppendInfallibleToAttrs(attrs, throws)
return attrs return attrs
@@ -435,6 +430,7 @@ class Descriptor(DescriptorProvider):
assert bool(getter) != bool(setter) assert bool(getter) != bool(setter)
key = 'getterOnly' if getter else 'setterOnly' key = 'getterOnly' if getter else 'setterOnly'
attrs = self.extendedAttributes['all'].get(name, []) + self.extendedAttributes[key].get(name, []) attrs = self.extendedAttributes['all'].get(name, []) + self.extendedAttributes[key].get(name, [])
throws = member.getExtendedAttribute("Throws")
if throws is None: if throws is None:
throwsAttr = "GetterThrows" if getter else "SetterThrows" throwsAttr = "GetterThrows" if getter else "SetterThrows"
throws = member.getExtendedAttribute(throwsAttr) throws = member.getExtendedAttribute(throwsAttr)

View File

@@ -475,12 +475,6 @@ class IDLExternalInterface(IDLObjectWithIdentifier):
def resolve(self, parentScope): def resolve(self, parentScope):
pass pass
def getJSImplementation(self):
return None
def isJSImplemented(self):
return False
def _getDependentObjects(self): def _getDependentObjects(self):
return set() return set()
@@ -779,7 +773,7 @@ class IDLInterface(IDLObjectWithScope):
return self._callback return self._callback
def isSingleOperationInterface(self): def isSingleOperationInterface(self):
assert self.isCallback() or self.isJSImplemented() assert self.isCallback()
return ( return (
# Not inheriting from another interface # Not inheriting from another interface
not self.parent and not self.parent and
@@ -962,17 +956,6 @@ class IDLInterface(IDLObjectWithScope):
# Put the new members at the beginning # Put the new members at the beginning
self.members = members + self.members self.members = members + self.members
def getJSImplementation(self):
classId = self.getExtendedAttribute("JSImplementation")
if not classId:
return classId
assert isinstance(classId, list)
assert len(classId) == 1
return classId[0]
def isJSImplemented(self):
return bool(self.getJSImplementation())
def _getDependentObjects(self): def _getDependentObjects(self):
deps = set(self.members) deps = set(self.members)
deps.union(self.implementedInterfaces) deps.union(self.implementedInterfaces)

View File

@@ -510,7 +510,7 @@ interface TestInterface {
[SetterThrows] attribute boolean throwingSetterAttr; [SetterThrows] attribute boolean throwingSetterAttr;
legacycaller short(unsigned long arg1, TestInterface arg2); legacycaller short(unsigned long arg1, TestInterface arg2);
// If you add things here, add them to TestExampleGen and TestJSImplGen as well // If you add things here, add them to TestExampleGen as well
}; };
interface TestParentInterface { interface TestParentInterface {

View File

@@ -424,7 +424,7 @@ interface TestExampleInterface {
[SetterThrows] attribute boolean throwingSetterAttr; [SetterThrows] attribute boolean throwingSetterAttr;
legacycaller short(unsigned long arg1, TestInterface arg2); legacycaller short(unsigned long arg1, TestInterface arg2);
// If you add things here, add them to TestCodeGen and TestJSImplGen as well // If you add things here, add them to TestCodeGen as well
}; };
interface TestExampleProxyInterface { interface TestExampleProxyInterface {

View File

@@ -1,430 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
typedef TestJSImplInterface AnotherNameForTestJSImplInterface;
typedef TestJSImplInterface YetAnotherNameForTestJSImplInterface;
typedef TestJSImplInterface? NullableTestJSImplInterface;
callback MyTestCallback = void();
TestInterface implements ImplementedInterface;
enum MyTestEnum {
"a",
"b"
};
[Constructor, JSImplementation="@mozilla.org/test-js-impl-interface;1"]
interface TestJSImplInterface {
// Integer types
// XXXbz add tests for throwing versions of all the integer stuff
readonly attribute byte readonlyByte;
attribute byte writableByte;
void passByte(byte arg);
byte receiveByte();
void passOptionalByte(optional byte arg);
// Callback interface limitation. See bug 841429.
// void passOptionalByteWithDefault(optional byte arg = 0);
void passNullableByte(byte? arg);
void passOptionalNullableByte(optional byte? arg);
void passVariadicByte(byte... arg);
readonly attribute short readonlyShort;
attribute short writableShort;
void passShort(short arg);
short receiveShort();
void passOptionalShort(optional short arg);
// Callback interface limitation. See bug 841429.
//void passOptionalShortWithDefault(optional short arg = 5);
readonly attribute long readonlyLong;
attribute long writableLong;
void passLong(long arg);
long receiveLong();
void passOptionalLong(optional long arg);
// Callback interface limitation. See bug 841429.
//void passOptionalLongWithDefault(optional long arg = 7);
readonly attribute long long readonlyLongLong;
attribute long long writableLongLong;
void passLongLong(long long arg);
long long receiveLongLong();
void passOptionalLongLong(optional long long arg);
// Callback interface limitation. See bug 841429.
//void passOptionalLongLongWithDefault(optional long long arg = -12);
readonly attribute octet readonlyOctet;
attribute octet writableOctet;
void passOctet(octet arg);
octet receiveOctet();
void passOptionalOctet(optional octet arg);
// Callback interface limitation. See bug 841429.
//void passOptionalOctetWithDefault(optional octet arg = 19);
readonly attribute unsigned short readonlyUnsignedShort;
attribute unsigned short writableUnsignedShort;
void passUnsignedShort(unsigned short arg);
unsigned short receiveUnsignedShort();
void passOptionalUnsignedShort(optional unsigned short arg);
// Callback interface limitation. See bug 841429.
//void passOptionalUnsignedShortWithDefault(optional unsigned short arg = 2);
readonly attribute unsigned long readonlyUnsignedLong;
attribute unsigned long writableUnsignedLong;
void passUnsignedLong(unsigned long arg);
unsigned long receiveUnsignedLong();
void passOptionalUnsignedLong(optional unsigned long arg);
// Callback interface limitation. See bug 841429.
//void passOptionalUnsignedLongWithDefault(optional unsigned long arg = 6);
readonly attribute unsigned long long readonlyUnsignedLongLong;
attribute unsigned long long writableUnsignedLongLong;
void passUnsignedLongLong(unsigned long long arg);
unsigned long long receiveUnsignedLongLong();
void passOptionalUnsignedLongLong(optional unsigned long long arg);
// Callback interface limitation. See bug 841429.
//void passOptionalUnsignedLongLongWithDefault(optional unsigned long long arg = 17);
attribute float writableFloat;
attribute unrestricted float writableUnrestrictedFloat;
attribute float? writableNullableFloat;
attribute unrestricted float? writableNullableUnrestrictedFloat;
attribute double writableDouble;
attribute unrestricted double writableUnrestrictedDouble;
attribute double? writableNullableDouble;
attribute unrestricted double? writableNullableUnrestrictedDouble;
void passFloat(float arg1, unrestricted float arg2,
float? arg3, unrestricted float? arg4,
double arg5, unrestricted double arg6,
double? arg7, unrestricted double? arg8,
sequence<float> arg9, sequence<unrestricted float> arg10,
sequence<float?> arg11, sequence<unrestricted float?> arg12,
sequence<double> arg13, sequence<unrestricted double> arg14,
sequence<double?> arg15, sequence<unrestricted double?> arg16);
[LenientFloat]
void passLenientFloat(float arg1, unrestricted float arg2,
float? arg3, unrestricted float? arg4,
double arg5, unrestricted double arg6,
double? arg7, unrestricted double? arg8,
sequence<float> arg9,
sequence<unrestricted float> arg10,
sequence<float?> arg11,
sequence<unrestricted float?> arg12,
sequence<double> arg13,
sequence<unrestricted double> arg14,
sequence<double?> arg15,
sequence<unrestricted double?> arg16);
[LenientFloat]
attribute float lenientFloatAttr;
[LenientFloat]
attribute double lenientDoubleAttr;
// Castable interface types
// XXXbz add tests for throwing versions of all the castable interface stuff
TestJSImplInterface receiveSelf();
TestJSImplInterface? receiveNullableSelf();
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
//TestJSImplInterface receiveWeakSelf();
//TestJSImplInterface? receiveWeakNullableSelf();
// A version to test for casting to TestJSImplInterface&
void passSelf(TestJSImplInterface arg);
// A version we can use to test for the exact type passed in
void passSelf2(TestJSImplInterface arg);
void passNullableSelf(TestJSImplInterface? arg);
attribute TestJSImplInterface nonNullSelf;
attribute TestJSImplInterface? nullableSelf;
// Optional arguments
void passOptionalSelf(optional TestJSImplInterface? arg);
void passOptionalNonNullSelf(optional TestJSImplInterface arg);
// Callback interface limitation. See bug 841429.
//void passOptionalSelfWithDefault(optional TestJSImplInterface? arg = null);
// Non-wrapper-cache interface types
[Creator]
TestNonWrapperCacheInterface receiveNonWrapperCacheInterface();
[Creator]
TestNonWrapperCacheInterface? receiveNullableNonWrapperCacheInterface();
// Can't return sequences of interfaces from callback interface methods. See bug 843264.
//[Creator]
//sequence<TestNonWrapperCacheInterface> receiveNonWrapperCacheInterfaceSequence();
//[Creator]
//sequence<TestNonWrapperCacheInterface?> receiveNullableNonWrapperCacheInterfaceSequence();
//[Creator]
//sequence<TestNonWrapperCacheInterface>? receiveNonWrapperCacheInterfaceNullableSequence();
//[Creator]
//sequence<TestNonWrapperCacheInterface?>? receiveNullableNonWrapperCacheInterfaceNullableSequence();
// Non-castable interface types
IndirectlyImplementedInterface receiveOther();
IndirectlyImplementedInterface? receiveNullableOther();
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
//IndirectlyImplementedInterface receiveWeakOther();
//IndirectlyImplementedInterface? receiveWeakNullableOther();
// A verstion to test for casting to IndirectlyImplementedInterface&
void passOther(IndirectlyImplementedInterface arg);
// A version we can use to test for the exact type passed in
void passOther2(IndirectlyImplementedInterface arg);
void passNullableOther(IndirectlyImplementedInterface? arg);
attribute IndirectlyImplementedInterface nonNullOther;
attribute IndirectlyImplementedInterface? nullableOther;
// Optional arguments
void passOptionalOther(optional IndirectlyImplementedInterface? arg);
void passOptionalNonNullOther(optional IndirectlyImplementedInterface arg);
// Callback interface limitation. See bug 841429.
//void passOptionalOtherWithDefault(optional IndirectlyImplementedInterface? arg = null);
// External interface types
TestExternalInterface receiveExternal();
TestExternalInterface? receiveNullableExternal();
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
//TestExternalInterface receiveWeakExternal();
//TestExternalInterface? receiveWeakNullableExternal();
// A verstion to test for casting to TestExternalInterface&
void passExternal(TestExternalInterface arg);
// A version we can use to test for the exact type passed in
void passExternal2(TestExternalInterface arg);
void passNullableExternal(TestExternalInterface? arg);
attribute TestExternalInterface nonNullExternal;
attribute TestExternalInterface? nullableExternal;
// Optional arguments
void passOptionalExternal(optional TestExternalInterface? arg);
void passOptionalNonNullExternal(optional TestExternalInterface arg);
// Callback interface limitation. See bug 841429.
//void passOptionalExternalWithDefault(optional TestExternalInterface? arg = null);
// Callback interface types
TestCallbackInterface receiveCallbackInterface();
TestCallbackInterface? receiveNullableCallbackInterface();
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
//TestCallbackInterface receiveWeakCallbackInterface();
//TestCallbackInterface? receiveWeakNullableCallbackInterface();
// A verstion to test for casting to TestCallbackInterface&
void passCallbackInterface(TestCallbackInterface arg);
// A version we can use to test for the exact type passed in
void passCallbackInterface2(TestCallbackInterface arg);
void passNullableCallbackInterface(TestCallbackInterface? arg);
attribute TestCallbackInterface nonNullCallbackInterface;
attribute TestCallbackInterface? nullableCallbackInterface;
// Optional arguments
void passOptionalCallbackInterface(optional TestCallbackInterface? arg);
void passOptionalNonNullCallbackInterface(optional TestCallbackInterface arg);
// Callback interface limitation. See bug 841429.
//void passOptionalCallbackInterfaceWithDefault(optional TestCallbackInterface? arg = null);
// Miscellaneous interface tests
IndirectlyImplementedInterface receiveConsequentialInterface();
void passConsequentialInterface(IndirectlyImplementedInterface arg);
// Sequence types
sequence<long> receiveSequence();
sequence<long>? receiveNullableSequence();
sequence<long?> receiveSequenceOfNullableInts();
sequence<long?>? receiveNullableSequenceOfNullableInts();
void passSequence(sequence<long> arg);
void passNullableSequence(sequence<long>? arg);
void passSequenceOfNullableInts(sequence<long?> arg);
void passOptionalSequenceOfNullableInts(optional sequence<long?> arg);
void passOptionalNullableSequenceOfNullableInts(optional sequence<long?>? arg);
// Can't return sequences of interfaces from callback interface methods. See bug 843264.
//sequence<TestJSImplInterface> receiveCastableObjectSequence();
//sequence<TestCallbackInterface> receiveCallbackObjectSequence();
//sequence<TestJSImplInterface?> receiveNullableCastableObjectSequence();
//sequence<TestCallbackInterface?> receiveNullableCallbackObjectSequence();
//sequence<TestJSImplInterface>? receiveCastableObjectNullableSequence();
//sequence<TestJSImplInterface?>? receiveNullableCastableObjectNullableSequence();
// Callback interface ignores 'resultNotAddRefed'. See bug 843272.
//sequence<TestJSImplInterface> receiveWeakCastableObjectSequence();
//sequence<TestJSImplInterface?> receiveWeakNullableCastableObjectSequence();
//sequence<TestJSImplInterface>? receiveWeakCastableObjectNullableSequence();
//sequence<TestJSImplInterface?>? receiveWeakNullableCastableObjectNullableSequence();
void passCastableObjectSequence(sequence<TestJSImplInterface> arg);
void passNullableCastableObjectSequence(sequence<TestJSImplInterface?> arg);
void passCastableObjectNullableSequence(sequence<TestJSImplInterface>? arg);
void passNullableCastableObjectNullableSequence(sequence<TestJSImplInterface?>? arg);
void passOptionalSequence(optional sequence<long> arg);
void passOptionalNullableSequence(optional sequence<long>? arg);
// Callback interface limitation. See bug 841429.
//void passOptionalNullableSequenceWithDefaultValue(optional sequence<long>? arg = null);
void passOptionalObjectSequence(optional sequence<TestJSImplInterface> arg);
void passExternalInterfaceSequence(sequence<TestExternalInterface> arg);
void passNullableExternalInterfaceSequence(sequence<TestExternalInterface?> arg);
// Can't return sequences of interfaces from callback interface methods. See bug 843264.
//sequence<DOMString> receiveStringSequence();
// Callback interface problem. See bug 843261.
//void passStringSequence(sequence<DOMString> arg);
// "Can't handle sequence member 'any'; need to sort out rooting issues"
//sequence<any> receiveAnySequence();
//sequence<any>? receiveNullableAnySequence();
// ArrayBuffer is handled differently in callback interfaces and the example generator.
// Need to figure out what should be done there. Seems like other typed array stuff is
// similarly not working in the JS implemented generator. Probably some other issues
// here as well.
// Typed array types
//void passArrayBuffer(ArrayBuffer arg);
//void passNullableArrayBuffer(ArrayBuffer? arg);
//void passOptionalArrayBuffer(optional ArrayBuffer arg);
//void passOptionalNullableArrayBuffer(optional ArrayBuffer? arg);
//void passOptionalNullableArrayBufferWithDefaultValue(optional ArrayBuffer? arg= null);
//void passArrayBufferView(ArrayBufferView arg);
//void passInt8Array(Int8Array arg);
//void passInt16Array(Int16Array arg);
//void passInt32Array(Int32Array arg);
//void passUint8Array(Uint8Array arg);
//void passUint16Array(Uint16Array arg);
//void passUint32Array(Uint32Array arg);
//void passUint8ClampedArray(Uint8ClampedArray arg);
//void passFloat32Array(Float32Array arg);
//void passFloat64Array(Float64Array arg);
//Uint8Array receiveUint8Array();
// String types
void passString(DOMString arg);
void passNullableString(DOMString? arg);
void passOptionalString(optional DOMString arg);
// Callback interface limitation. See bug 841429.
//void passOptionalStringWithDefaultValue(optional DOMString arg = "abc");
void passOptionalNullableString(optional DOMString? arg);
// Callback interface limitation. See bug 841429.
//void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null);
void passVariadicString(DOMString... arg);
// Enumerated types
void passEnum(MyTestEnum arg);
// No support for nullable enums yet
// void passNullableEnum(MyTestEnum? arg);
// Optional enum arg doesn't work with callback interfaces. See bug 843355.
//void passOptionalEnum(optional MyTestEnum arg);
// Callback interface limitation. See bug 841429.
//void passEnumWithDefault(optional MyTestEnum arg = "a");
// void passOptionalNullableEnum(optional MyTestEnum? arg);
// void passOptionalNullableEnumWithDefaultValue(optional MyTestEnum? arg = null);
MyTestEnum receiveEnum();
attribute MyTestEnum enumAttribute;
readonly attribute MyTestEnum readonlyEnumAttribute;
// Callback types
void passCallback(MyTestCallback arg);
void passNullableCallback(MyTestCallback? arg);
void passOptionalCallback(optional MyTestCallback arg);
void passOptionalNullableCallback(optional MyTestCallback? arg);
// Callback interface limitation. See bug 841429.
//void passOptionalNullableCallbackWithDefaultValue(optional MyTestCallback? arg = null);
MyTestCallback receiveCallback();
MyTestCallback? receiveNullableCallback();
// Hmm. These two don't work, I think because I need a locally modified version of TestTreatAsNullCallback.
//void passNullableTreatAsNullCallback(TestTreatAsNullCallback? arg);
//void passOptionalNullableTreatAsNullCallback(optional TestTreatAsNullCallback? arg);
// Callback interface limitation. See bug 841429.
//void passOptionalNullableTreatAsNullCallbackWithDefaultValue(optional TestTreatAsNullCallback? arg = null);
/* The rest of these are untested.
// Any types
void passAny(any arg);
void passOptionalAny(optional any arg);
void passAnyDefaultNull(optional any arg = null);
any receiveAny();
// object types
void passObject(object arg);
void passNullableObject(object? arg);
void passOptionalObject(optional object arg);
void passOptionalNullableObject(optional object? arg);
void passOptionalNullableObjectWithDefaultValue(optional object? arg = null);
object receiveObject();
object? receiveNullableObject();
// Union types
void passUnion((object or long) arg);
void passUnionWithNullable((object? or long) arg);
void passNullableUnion((object or long)? arg);
void passOptionalUnion(optional (object or long) arg);
void passOptionalNullableUnion(optional (object or long)? arg);
void passOptionalNullableUnionWithDefaultValue(optional (object or long)? arg = null);
//void passUnionWithInterfaces((TestJSImplInterface or TestExternalInterface) arg);
//void passUnionWithInterfacesAndNullable((TestJSImplInterface? or TestExternalInterface) arg);
//void passUnionWithSequence((sequence<object> or long) arg);
void passUnionWithArrayBuffer((ArrayBuffer or long) arg);
void passUnionWithString((DOMString or object) arg);
//void passUnionWithEnum((MyTestEnum or object) arg);
// Trying to use a callback in a union won't include the test
// headers, unfortunately, so won't compile.
// void passUnionWithCallback((MyTestCallback or long) arg);
void passUnionWithObject((object or long) arg);
//void passUnionWithDict((Dict or long) arg);
// binaryNames tests
void methodRenamedFrom();
void methodRenamedFrom(byte argument);
readonly attribute byte attributeGetterRenamedFrom;
attribute byte attributeRenamedFrom;
void passDictionary(optional Dict x);
//UNSUPPORTED Dict receiveDictionary();
void passOtherDictionary(optional GrandparentDict x);
void passSequenceOfDictionaries(sequence<Dict> x);
void passDictionaryOrLong(optional Dict x);
void passDictionaryOrLong(long x);
void passDictContainingDict(optional DictContainingDict arg);
void passDictContainingSequence(optional DictContainingSequence arg);
//UNSUPPORTED DictContainingSequence receiveDictContainingSequence();
// EnforceRange/Clamp tests
void dontEnforceRangeOrClamp(byte arg);
void doEnforceRange([EnforceRange] byte arg);
void doClamp([Clamp] byte arg);
// Typedefs
const myLong myLongConstant = 5;
// ???? What
void exerciseTypedefInterfaces1(AnotherNameForTestJSImplInterface arg);
AnotherNameForTestJSImplInterface exerciseTypedefInterfaces2(NullableTestJSImplInterface arg);
void exerciseTypedefInterfaces3(YetAnotherNameForTestJSImplInterface arg);
// Static methods and attributes
static attribute boolean staticAttribute;
static void staticMethod(boolean arg);
static void staticMethodWithContext(any arg);
// Overload resolution tests
//void overload1(DOMString... strs);
boolean overload1(TestJSImplInterface arg);
TestJSImplInterface overload1(DOMString strs, TestJSImplInterface arg);
void overload2(TestJSImplInterface arg);
void overload2(optional Dict arg);
void overload2(DOMString arg);
void overload3(TestJSImplInterface arg);
void overload3(MyTestCallback arg);
void overload3(DOMString arg);
void overload4(TestJSImplInterface arg);
void overload4(TestCallbackInterface arg);
void overload4(DOMString arg);
// Variadic handling
void passVariadicThirdArg(DOMString arg1, long arg2, TestJSImplInterface... arg3);
// Miscellania
[LenientThis] attribute long attrWithLenientThis;
[Unforgeable] readonly attribute long unforgeableAttr;
[Unforgeable, ChromeOnly] readonly attribute long unforgeableAttr2;
stringifier;
void passRenamedInterface(TestRenamedInterface arg);
[PutForwards=writableByte] readonly attribute TestJSImplInterface putForwardsAttr;
[PutForwards=writableByte, LenientThis] readonly attribute TestJSImplInterface putForwardsAttr2;
[PutForwards=writableByte, ChromeOnly] readonly attribute TestJSImplInterface putForwardsAttr3;
[Throws] void throwingMethod();
[Throws] attribute boolean throwingAttr;
[GetterThrows] attribute boolean throwingGetterAttr;
[SetterThrows] attribute boolean throwingSetterAttr;
*/
// If you add things here, add them to TestCodeGen as well
};

View File

@@ -293,7 +293,6 @@ test_webidl_files := \
TestCodeGen.webidl \ TestCodeGen.webidl \
TestDictionary.webidl \ TestDictionary.webidl \
TestExampleGen.webidl \ TestExampleGen.webidl \
TestJSImplGen.webidl \
TestTypedef.webidl \ TestTypedef.webidl \
$(NULL) $(NULL)
else else