mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Simplify CGConstructorEnabled.
This commit is contained in:
parent
28630f5487
commit
4c31c8ac7b
1 changed files with 3 additions and 15 deletions
|
@ -2245,8 +2245,6 @@ class CGConstructorEnabled(CGAbstractMethod):
|
||||||
unsafe_fn=True)
|
unsafe_fn=True)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
body = CGList([], "\n")
|
|
||||||
|
|
||||||
conditions = []
|
conditions = []
|
||||||
iface = self.descriptor.interface
|
iface = self.descriptor.interface
|
||||||
|
|
||||||
|
@ -2254,25 +2252,15 @@ class CGConstructorEnabled(CGAbstractMethod):
|
||||||
if pref:
|
if pref:
|
||||||
assert isinstance(pref, list) and len(pref) == 1
|
assert isinstance(pref, list) and len(pref) == 1
|
||||||
conditions.append('PREFS.get("%s").as_boolean().unwrap_or(false)' % pref[0])
|
conditions.append('PREFS.get("%s").as_boolean().unwrap_or(false)' % pref[0])
|
||||||
|
|
||||||
func = iface.getExtendedAttribute("Func")
|
func = iface.getExtendedAttribute("Func")
|
||||||
if func:
|
if func:
|
||||||
assert isinstance(func, list) and len(func) == 1
|
assert isinstance(func, list) and len(func) == 1
|
||||||
conditions.append("%s(aCx, aObj)" % func[0])
|
conditions.append("%s(aCx, aObj)" % func[0])
|
||||||
# We should really have some conditions
|
|
||||||
assert len(body) or len(conditions)
|
|
||||||
|
|
||||||
conditionsWrapper = ""
|
assert conditions
|
||||||
if len(conditions):
|
|
||||||
conditionsWrapper = CGWrapper(CGList((CGGeneric(cond) for cond in conditions),
|
|
||||||
" &&\n"),
|
|
||||||
pre="return ",
|
|
||||||
post=";\n",
|
|
||||||
reindent=True)
|
|
||||||
else:
|
|
||||||
conditionsWrapper = CGGeneric("return true;\n")
|
|
||||||
|
|
||||||
body.append(conditionsWrapper)
|
return CGList((CGGeneric(cond) for cond in conditions), " &&\n")
|
||||||
return body
|
|
||||||
|
|
||||||
|
|
||||||
def CreateBindingJSObject(descriptor, parent=None):
|
def CreateBindingJSObject(descriptor, parent=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue