mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove some code to support preffing off APIs.
We won't be using this feature in the near future, and the implementation is not really Rustic.
This commit is contained in:
parent
999fc973c0
commit
3dece6b7ab
1 changed files with 6 additions and 46 deletions
|
@ -1062,7 +1062,7 @@ class PropertyDefiner:
|
||||||
return prefName[0]
|
return prefName[0]
|
||||||
|
|
||||||
def generatePrefableArray(self, array, name, specTemplate, specTerminator,
|
def generatePrefableArray(self, array, name, specTemplate, specTerminator,
|
||||||
specType, getPref, getDataTuple):
|
specType, getDataTuple):
|
||||||
"""
|
"""
|
||||||
This method generates our various arrays.
|
This method generates our various arrays.
|
||||||
|
|
||||||
|
@ -1072,58 +1072,21 @@ class PropertyDefiner:
|
||||||
|
|
||||||
specTemplate is a template for each entry of the spec array
|
specTemplate is a template for each entry of the spec array
|
||||||
|
|
||||||
specTerminator is a terminator for the spec array (inserted every time
|
specTerminator is a terminator for the spec array (inserted at the end
|
||||||
our controlling pref changes and at the end of the array)
|
of the array)
|
||||||
|
|
||||||
specType is the actual typename of our spec
|
specType is the actual typename of our spec
|
||||||
|
|
||||||
getPref is a callback function that takes an array entry and returns
|
|
||||||
the corresponding pref value.
|
|
||||||
|
|
||||||
getDataTuple is a callback function that takes an array entry and
|
getDataTuple is a callback function that takes an array entry and
|
||||||
returns a tuple suitable for substitution into specTemplate.
|
returns a tuple suitable for substitution into specTemplate.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# We want to generate a single list of specs, but with specTerminator
|
|
||||||
# inserted at every point where the pref name controlling the member
|
|
||||||
# changes. That will make sure the order of the properties as exposed
|
|
||||||
# on the interface and interface prototype objects does not change when
|
|
||||||
# pref control is added to members while still allowing us to define all
|
|
||||||
# the members in the smallest number of JSAPI calls.
|
|
||||||
assert(len(array) is not 0)
|
assert(len(array) is not 0)
|
||||||
lastPref = getPref(array[0]) # So we won't put a specTerminator
|
|
||||||
# at the very front of the list.
|
|
||||||
specs = []
|
specs = []
|
||||||
prefableSpecs = []
|
|
||||||
|
|
||||||
prefableTemplate = ' { true, &%s[%d] }'
|
|
||||||
prefCacheTemplate = '&%s[%d].enabled'
|
|
||||||
def switchToPref(props, pref):
|
|
||||||
# Remember the info about where our pref-controlled
|
|
||||||
# booleans live.
|
|
||||||
if pref is not None:
|
|
||||||
props.prefCacheData.append(
|
|
||||||
(pref, prefCacheTemplate % (name, len(prefableSpecs)))
|
|
||||||
)
|
|
||||||
# Set up pointers to the new sets of specs and ids
|
|
||||||
# inside prefableSpecs and prefableIds
|
|
||||||
prefableSpecs.append(prefableTemplate %
|
|
||||||
(name + "_specs", len(specs)))
|
|
||||||
|
|
||||||
switchToPref(self, lastPref)
|
|
||||||
|
|
||||||
for member in array:
|
for member in array:
|
||||||
curPref = getPref(member)
|
|
||||||
if lastPref != curPref:
|
|
||||||
# Terminate previous list
|
|
||||||
specs.append(specTerminator)
|
|
||||||
# And switch to our new pref
|
|
||||||
switchToPref(self, curPref)
|
|
||||||
lastPref = curPref
|
|
||||||
# And the actual spec
|
|
||||||
specs.append(specTemplate % getDataTuple(member))
|
specs.append(specTemplate % getDataTuple(member))
|
||||||
specs.append(specTerminator)
|
specs.append(specTerminator)
|
||||||
prefableSpecs.append(" { false, NULL }");
|
|
||||||
|
|
||||||
return (("static %s: [%s, ..%i] = [\n" +
|
return (("static %s: [%s, ..%i] = [\n" +
|
||||||
",\n".join(specs) + "\n" +
|
",\n".join(specs) + "\n" +
|
||||||
|
@ -1194,9 +1157,6 @@ class MethodDefiner(PropertyDefiner):
|
||||||
if len(array) == 0:
|
if len(array) == 0:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def pref(m):
|
|
||||||
return m["pref"]
|
|
||||||
|
|
||||||
def specData(m):
|
def specData(m):
|
||||||
if m.get("methodInfo", True):
|
if m.get("methodInfo", True):
|
||||||
jitinfo = ("&%s_methodinfo" % m["name"])
|
jitinfo = ("&%s_methodinfo" % m["name"])
|
||||||
|
@ -1216,7 +1176,7 @@ class MethodDefiner(PropertyDefiner):
|
||||||
' JSFunctionSpec {name: &%s_name as *u8 as *libc::c_char, call: JSNativeWrapper {op: Some(%s), info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *libc::c_char }',
|
' JSFunctionSpec {name: &%s_name as *u8 as *libc::c_char, call: JSNativeWrapper {op: Some(%s), info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *libc::c_char }',
|
||||||
' JSFunctionSpec {name: 0 as *libc::c_char, call: JSNativeWrapper {op: None, info: 0 as *JSJitInfo}, nargs: 0, flags: 0, selfHostedName: 0 as *libc::c_char }',
|
' JSFunctionSpec {name: 0 as *libc::c_char, call: JSNativeWrapper {op: None, info: 0 as *JSJitInfo}, nargs: 0, flags: 0, selfHostedName: 0 as *libc::c_char }',
|
||||||
'JSFunctionSpec',
|
'JSFunctionSpec',
|
||||||
pref, specData)
|
specData)
|
||||||
|
|
||||||
class AttrDefiner(PropertyDefiner):
|
class AttrDefiner(PropertyDefiner):
|
||||||
def __init__(self, descriptor, name):
|
def __init__(self, descriptor, name):
|
||||||
|
@ -1264,7 +1224,7 @@ class AttrDefiner(PropertyDefiner):
|
||||||
' JSPropertySpec { name: &%s_name as *u8 as *libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }',
|
' JSPropertySpec { name: &%s_name as *u8 as *libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }',
|
||||||
' JSPropertySpec { name: 0 as *libc::c_char, tinyid: 0, flags: 0, getter: JSPropertyOpWrapper {op: None, info: 0 as *JSJitInfo}, setter: JSStrictPropertyOpWrapper {op: None, info: 0 as *JSJitInfo} }',
|
' JSPropertySpec { name: 0 as *libc::c_char, tinyid: 0, flags: 0, getter: JSPropertyOpWrapper {op: None, info: 0 as *JSJitInfo}, setter: JSStrictPropertyOpWrapper {op: None, info: 0 as *JSJitInfo} }',
|
||||||
'JSPropertySpec',
|
'JSPropertySpec',
|
||||||
PropertyDefiner.getControllingPref, specData)
|
specData)
|
||||||
|
|
||||||
class ConstDefiner(PropertyDefiner):
|
class ConstDefiner(PropertyDefiner):
|
||||||
"""
|
"""
|
||||||
|
@ -1296,7 +1256,7 @@ class ConstDefiner(PropertyDefiner):
|
||||||
' ConstantSpec { name: &%s_name as *u8 as *libc::c_char, value: %s }',
|
' ConstantSpec { name: &%s_name as *u8 as *libc::c_char, value: %s }',
|
||||||
' ConstantSpec { name: 0 as *libc::c_char, value: VoidVal }',
|
' ConstantSpec { name: 0 as *libc::c_char, value: VoidVal }',
|
||||||
'ConstantSpec',
|
'ConstantSpec',
|
||||||
PropertyDefiner.getControllingPref, specData)
|
specData)
|
||||||
|
|
||||||
# We'll want to insert the indent at the beginnings of lines, but we
|
# We'll want to insert the indent at the beginnings of lines, but we
|
||||||
# don't want to indent empty lines. So only indent lines that have a
|
# don't want to indent empty lines. So only indent lines that have a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue