mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 900994. Add support for Func annotations on interface objects. r=smaug
This commit is contained in:
parent
c8a7f5db48
commit
78a9c682d9
@ -650,13 +650,15 @@ class CGHeaders(CGWrapper):
|
||||
for desc in descriptors:
|
||||
if desc.interface.isExternal():
|
||||
continue
|
||||
for m in desc.interface.members:
|
||||
func = PropertyDefiner.getStringAttr(m, "Func")
|
||||
def addHeaderForFunc(func):
|
||||
# Include the right class header, which we can only do
|
||||
# if this is a class member function.
|
||||
if func is not None and "::" in func:
|
||||
# Strip out the function name and convert "::" to "/"
|
||||
bindingHeaders.add("/".join(func.split("::")[:-1]) + ".h")
|
||||
for m in desc.interface.members:
|
||||
addHeaderForFunc(PropertyDefiner.getStringAttr(m, "Func"))
|
||||
addHeaderForFunc(desc.interface.getExtendedAttribute("Func"))
|
||||
|
||||
for d in dictionaries:
|
||||
if d.parent:
|
||||
@ -1940,7 +1942,7 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||
|
||||
""" + getConstructor)
|
||||
|
||||
class CGPrefEnabledNative(CGAbstractMethod):
|
||||
class CGConstructorEnabledViaPrefEnabled(CGAbstractMethod):
|
||||
"""
|
||||
A method for testing whether the preference controlling this
|
||||
interface is enabled. This delegates to PrefEnabled() on the
|
||||
@ -1957,7 +1959,7 @@ class CGPrefEnabledNative(CGAbstractMethod):
|
||||
def definition_body(self):
|
||||
return " return %s::PrefEnabled();" % self.descriptor.nativeType
|
||||
|
||||
class CGPrefEnabled(CGAbstractMethod):
|
||||
class CGConstructorEnabledViaPref(CGAbstractMethod):
|
||||
"""
|
||||
A method for testing whether the preference controlling this
|
||||
interface is enabled. This generates code in the binding to
|
||||
@ -1992,6 +1994,22 @@ class CGConstructorEnabledChromeOnly(CGAbstractMethod):
|
||||
def definition_body(self):
|
||||
return " return %s;" % GetAccessCheck(self.descriptor, "aObj")
|
||||
|
||||
class CGConstructorEnabledViaFunc(CGAbstractMethod):
|
||||
"""
|
||||
A method for testing whether the interface object should be exposed on a
|
||||
given global based on whatever the callee wants to consider.
|
||||
"""
|
||||
def __init__(self, descriptor):
|
||||
CGAbstractMethod.__init__(self, descriptor,
|
||||
'ConstructorEnabled', 'bool',
|
||||
[Argument("JSContext*", "cx"),
|
||||
Argument("JS::Handle<JSObject*>", "obj")])
|
||||
|
||||
def definition_body(self):
|
||||
func = self.descriptor.interface.getExtendedAttribute("Func")
|
||||
assert isinstance(func, list) and len(func) == 1
|
||||
return " return %s(cx, obj);" % func[0]
|
||||
|
||||
class CGIsMethod(CGAbstractMethod):
|
||||
def __init__(self, descriptor):
|
||||
args = [Argument('JSObject*', 'obj')]
|
||||
@ -7963,17 +7981,21 @@ class CGDescriptor(CGThing):
|
||||
prefControlled = descriptor.interface.getExtendedAttribute("PrefControlled")
|
||||
havePref = descriptor.interface.getExtendedAttribute("Pref")
|
||||
haveChromeOnly = descriptor.interface.getExtendedAttribute("ChromeOnly")
|
||||
haveFunc = descriptor.interface.getExtendedAttribute("Func")
|
||||
# Make sure at most one of those is set
|
||||
if bool(prefControlled) + bool(havePref) + bool(haveChromeOnly) > 1:
|
||||
if (bool(prefControlled) + bool(havePref) +
|
||||
bool(haveChromeOnly) + bool(haveFunc) > 1):
|
||||
raise TypeError("Interface %s has more than one of "
|
||||
"'PrefControlled', 'Pref', and 'ChomeOnly' "
|
||||
"specified", descriptor.name)
|
||||
"'PrefControlled', 'Pref', 'Func', and "
|
||||
"'ChomeOnly' specified", descriptor.name)
|
||||
if prefControlled is not None:
|
||||
cgThings.append(CGPrefEnabledNative(descriptor))
|
||||
cgThings.append(CGConstructorEnabledViaPrefEnabled(descriptor))
|
||||
elif havePref is not None:
|
||||
cgThings.append(CGPrefEnabled(descriptor))
|
||||
cgThings.append(CGConstructorEnabledViaPref(descriptor))
|
||||
elif haveChromeOnly is not None:
|
||||
cgThings.append(CGConstructorEnabledChromeOnly(descriptor))
|
||||
elif haveFunc is not None:
|
||||
cgThings.append(CGConstructorEnabledViaFunc(descriptor))
|
||||
|
||||
if descriptor.concrete:
|
||||
if descriptor.proxy:
|
||||
@ -8499,7 +8521,8 @@ class CGRegisterProtos(CGAbstractMethod):
|
||||
def getCheck(desc):
|
||||
if (desc.interface.getExtendedAttribute("PrefControlled") is None and
|
||||
desc.interface.getExtendedAttribute("Pref") is None and
|
||||
desc.interface.getExtendedAttribute("ChromeOnly") is None):
|
||||
desc.interface.getExtendedAttribute("ChromeOnly") is None and
|
||||
desc.interface.getExtendedAttribute("Func") is None):
|
||||
return "nullptr"
|
||||
return "%sBinding::ConstructorEnabled" % desc.name
|
||||
lines = []
|
||||
|
@ -932,7 +932,8 @@ class IDLInterface(IDLObjectWithScope):
|
||||
elif (identifier == "Pref" or
|
||||
identifier == "JSImplementation" or
|
||||
identifier == "HeaderFile" or
|
||||
identifier == "NavigatorProperty"):
|
||||
identifier == "NavigatorProperty" or
|
||||
identifier == "Func"):
|
||||
# Known extended attributes that take a string value
|
||||
if not attr.hasValue():
|
||||
raise WebIDLError("[%s] must have a value" % identifier,
|
||||
|
Loading…
Reference in New Issue
Block a user