зеркало из https://github.com/mozilla/gecko-dev.git
Bug 958667 part 4. Hook up an AvailableIn extended attribute for interfaces. r=peterv
This commit is contained in:
Родитель
f9ba8ad57a
Коммит
4ecbf2387a
|
@ -1301,6 +1301,17 @@ class CGClassHasInstanceHook(CGAbstractStaticMethod):
|
|||
def isChromeOnly(m):
|
||||
return m.getExtendedAttribute("ChromeOnly")
|
||||
|
||||
def getAvailableInTestFunc(obj):
|
||||
availableIn = obj.getExtendedAttribute("AvailableIn")
|
||||
if availableIn is None:
|
||||
return None
|
||||
assert isinstance(availableIn, list) and len(availableIn) == 1
|
||||
if availableIn[0] == "PrivilegedApps":
|
||||
return "IsInPrivilegedApp"
|
||||
if availableIn[0] == "CertifiedApps":
|
||||
return "IsInCertifiedApp"
|
||||
raise TypeError("Unknown AvailableIn value '%s'" % availableIn[0])
|
||||
|
||||
class MemberCondition:
|
||||
"""
|
||||
An object representing the condition for a member to actually be
|
||||
|
@ -2118,6 +2129,9 @@ class CGConstructorEnabled(CGAbstractMethod):
|
|||
conditions.append("%s(aCx, aObj)" % func[0])
|
||||
if iface.getExtendedAttribute("PrefControlled"):
|
||||
conditions.append("%s::PrefEnabled()" % self.descriptor.nativeType)
|
||||
availableIn = getAvailableInTestFunc(iface)
|
||||
if availableIn:
|
||||
conditions.append("%s(aCx, aObj)" % availableIn)
|
||||
# We should really have some conditions
|
||||
assert len(conditions)
|
||||
body = CGWrapper(CGList((CGGeneric(cond) for cond in conditions),
|
||||
|
|
|
@ -492,7 +492,8 @@ class Descriptor(DescriptorProvider):
|
|||
return (self.interface.getExtendedAttribute("Pref") or
|
||||
self.interface.getExtendedAttribute("ChromeOnly") or
|
||||
self.interface.getExtendedAttribute("Func") or
|
||||
self.interface.getExtendedAttribute("PrefControlled"))
|
||||
self.interface.getExtendedAttribute("PrefControlled") or
|
||||
self.interface.getExtendedAttribute("AvailableIn"))
|
||||
|
||||
# Some utility methods
|
||||
def getTypesFromDescriptor(descriptor):
|
||||
|
|
|
@ -977,6 +977,7 @@ class IDLInterface(IDLObjectWithScope):
|
|||
identifier == "JSImplementation" or
|
||||
identifier == "HeaderFile" or
|
||||
identifier == "NavigatorProperty" or
|
||||
identifier == "AvailableIn" or
|
||||
identifier == "Func"):
|
||||
# Known extended attributes that take a string value
|
||||
if not attr.hasValue():
|
||||
|
@ -2813,6 +2814,7 @@ class IDLAttribute(IDLInterfaceMember):
|
|||
identifier == "Constant" or
|
||||
identifier == "Func" or
|
||||
identifier == "Frozen" or
|
||||
identifier == "AvailableIn" or
|
||||
identifier == "NewObject"):
|
||||
# Known attributes that we don't need to do anything with here
|
||||
pass
|
||||
|
@ -3363,6 +3365,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
|||
identifier == "ChromeOnly" or
|
||||
identifier == "Pref" or
|
||||
identifier == "Func" or
|
||||
identifier == "AvailableIn" or
|
||||
identifier == "Pure" or
|
||||
identifier == "CrossOriginCallable" or
|
||||
identifier == "WebGLHandlesContextLoss"):
|
||||
|
|
|
@ -10,6 +10,7 @@ typedef TestInterface? NullableTestInterface;
|
|||
|
||||
interface TestExternalInterface;
|
||||
|
||||
[AvailableIn=PrivilegedApps, Pref="xyz"]
|
||||
interface TestRenamedInterface {
|
||||
};
|
||||
|
||||
|
@ -105,6 +106,7 @@ interface OnlyForUseInConstructor {
|
|||
Constructor(long arg1, IndirectlyImplementedInterface iface),
|
||||
Constructor(Date arg1),
|
||||
// Constructor(long arg1, long arg2, (TestInterface or OnlyForUseInConstructor) arg3),
|
||||
AvailableIn=CertifiedApps,
|
||||
NamedConstructor=Test,
|
||||
NamedConstructor=Test(DOMString str),
|
||||
NamedConstructor=Test2(DictForConstructor dict, any any1, object obj1,
|
||||
|
|
Загрузка…
Ссылка в новой задаче