зеркало из 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):
|
def isChromeOnly(m):
|
||||||
return m.getExtendedAttribute("ChromeOnly")
|
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:
|
class MemberCondition:
|
||||||
"""
|
"""
|
||||||
An object representing the condition for a member to actually be
|
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])
|
conditions.append("%s(aCx, aObj)" % func[0])
|
||||||
if iface.getExtendedAttribute("PrefControlled"):
|
if iface.getExtendedAttribute("PrefControlled"):
|
||||||
conditions.append("%s::PrefEnabled()" % self.descriptor.nativeType)
|
conditions.append("%s::PrefEnabled()" % self.descriptor.nativeType)
|
||||||
|
availableIn = getAvailableInTestFunc(iface)
|
||||||
|
if availableIn:
|
||||||
|
conditions.append("%s(aCx, aObj)" % availableIn)
|
||||||
# We should really have some conditions
|
# We should really have some conditions
|
||||||
assert len(conditions)
|
assert len(conditions)
|
||||||
body = CGWrapper(CGList((CGGeneric(cond) for cond in conditions),
|
body = CGWrapper(CGList((CGGeneric(cond) for cond in conditions),
|
||||||
|
|
|
@ -492,7 +492,8 @@ class Descriptor(DescriptorProvider):
|
||||||
return (self.interface.getExtendedAttribute("Pref") or
|
return (self.interface.getExtendedAttribute("Pref") or
|
||||||
self.interface.getExtendedAttribute("ChromeOnly") or
|
self.interface.getExtendedAttribute("ChromeOnly") or
|
||||||
self.interface.getExtendedAttribute("Func") or
|
self.interface.getExtendedAttribute("Func") or
|
||||||
self.interface.getExtendedAttribute("PrefControlled"))
|
self.interface.getExtendedAttribute("PrefControlled") or
|
||||||
|
self.interface.getExtendedAttribute("AvailableIn"))
|
||||||
|
|
||||||
# Some utility methods
|
# Some utility methods
|
||||||
def getTypesFromDescriptor(descriptor):
|
def getTypesFromDescriptor(descriptor):
|
||||||
|
|
|
@ -977,6 +977,7 @@ class IDLInterface(IDLObjectWithScope):
|
||||||
identifier == "JSImplementation" or
|
identifier == "JSImplementation" or
|
||||||
identifier == "HeaderFile" or
|
identifier == "HeaderFile" or
|
||||||
identifier == "NavigatorProperty" or
|
identifier == "NavigatorProperty" or
|
||||||
|
identifier == "AvailableIn" or
|
||||||
identifier == "Func"):
|
identifier == "Func"):
|
||||||
# Known extended attributes that take a string value
|
# Known extended attributes that take a string value
|
||||||
if not attr.hasValue():
|
if not attr.hasValue():
|
||||||
|
@ -2813,6 +2814,7 @@ class IDLAttribute(IDLInterfaceMember):
|
||||||
identifier == "Constant" or
|
identifier == "Constant" or
|
||||||
identifier == "Func" or
|
identifier == "Func" or
|
||||||
identifier == "Frozen" or
|
identifier == "Frozen" or
|
||||||
|
identifier == "AvailableIn" or
|
||||||
identifier == "NewObject"):
|
identifier == "NewObject"):
|
||||||
# Known attributes that we don't need to do anything with here
|
# Known attributes that we don't need to do anything with here
|
||||||
pass
|
pass
|
||||||
|
@ -3363,6 +3365,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
||||||
identifier == "ChromeOnly" or
|
identifier == "ChromeOnly" or
|
||||||
identifier == "Pref" or
|
identifier == "Pref" or
|
||||||
identifier == "Func" or
|
identifier == "Func" or
|
||||||
|
identifier == "AvailableIn" or
|
||||||
identifier == "Pure" or
|
identifier == "Pure" or
|
||||||
identifier == "CrossOriginCallable" or
|
identifier == "CrossOriginCallable" or
|
||||||
identifier == "WebGLHandlesContextLoss"):
|
identifier == "WebGLHandlesContextLoss"):
|
||||||
|
|
|
@ -10,6 +10,7 @@ typedef TestInterface? NullableTestInterface;
|
||||||
|
|
||||||
interface TestExternalInterface;
|
interface TestExternalInterface;
|
||||||
|
|
||||||
|
[AvailableIn=PrivilegedApps, Pref="xyz"]
|
||||||
interface TestRenamedInterface {
|
interface TestRenamedInterface {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,6 +106,7 @@ interface OnlyForUseInConstructor {
|
||||||
Constructor(long arg1, IndirectlyImplementedInterface iface),
|
Constructor(long arg1, IndirectlyImplementedInterface iface),
|
||||||
Constructor(Date arg1),
|
Constructor(Date arg1),
|
||||||
// Constructor(long arg1, long arg2, (TestInterface or OnlyForUseInConstructor) arg3),
|
// Constructor(long arg1, long arg2, (TestInterface or OnlyForUseInConstructor) arg3),
|
||||||
|
AvailableIn=CertifiedApps,
|
||||||
NamedConstructor=Test,
|
NamedConstructor=Test,
|
||||||
NamedConstructor=Test(DOMString str),
|
NamedConstructor=Test(DOMString str),
|
||||||
NamedConstructor=Test2(DictForConstructor dict, any any1, object obj1,
|
NamedConstructor=Test2(DictForConstructor dict, any any1, object obj1,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче