mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Remove Prefable::terminator 🤖
This commit is contained in:
parent
adcecda047
commit
a20db08f06
3 changed files with 17 additions and 17 deletions
|
@ -1409,8 +1409,7 @@ class PropertyDefiner:
|
||||||
assert len(array) != 0
|
assert len(array) != 0
|
||||||
specs = []
|
specs = []
|
||||||
prefableSpecs = []
|
prefableSpecs = []
|
||||||
prefableTemplate = ' Prefable { pref: %s, specs: %s[%d], terminator: %s }'
|
prefableTemplate = ' Prefable { pref: %s, specs: %s[%d] }'
|
||||||
hasTerminator = 'true' if specTerminator else 'false'
|
|
||||||
|
|
||||||
for cond, members in groupby(array, lambda m: getCondition(m, self.descriptor)):
|
for cond, members in groupby(array, lambda m: getCondition(m, self.descriptor)):
|
||||||
currentSpecs = [specTemplate % getDataTuple(m) for m in members]
|
currentSpecs = [specTemplate % getDataTuple(m) for m in members]
|
||||||
|
@ -1418,7 +1417,7 @@ class PropertyDefiner:
|
||||||
currentSpecs.append(specTerminator)
|
currentSpecs.append(specTerminator)
|
||||||
specs.append("&[\n" + ",\n".join(currentSpecs) + "]\n")
|
specs.append("&[\n" + ",\n".join(currentSpecs) + "]\n")
|
||||||
prefableSpecs.append(
|
prefableSpecs.append(
|
||||||
prefableTemplate % (cond, name + "_specs", len(specs) - 1, hasTerminator))
|
prefableTemplate % (cond, name + "_specs", len(specs) - 1))
|
||||||
|
|
||||||
specsArray = ("const %s_specs: &'static [&'static[%s]] = &[\n" +
|
specsArray = ("const %s_specs: &'static [&'static[%s]] = &[\n" +
|
||||||
",\n".join(specs) + "\n" +
|
",\n".join(specs) + "\n" +
|
||||||
|
|
|
@ -216,7 +216,9 @@ pub unsafe fn create_callback_interface_object(
|
||||||
rval.set(JS_NewObject(cx, ptr::null()));
|
rval.set(JS_NewObject(cx, ptr::null()));
|
||||||
assert!(!rval.ptr.is_null());
|
assert!(!rval.ptr.is_null());
|
||||||
for prefable in constants {
|
for prefable in constants {
|
||||||
define_constants(cx, rval.handle(), prefable.specs());
|
if let Some(specs) = prefable.specs() {
|
||||||
|
define_constants(cx, rval.handle(), specs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
define_name(cx, rval.handle(), name);
|
define_name(cx, rval.handle(), name);
|
||||||
define_on_global_object(cx, receiver, name, rval.handle());
|
define_on_global_object(cx, receiver, name, rval.handle());
|
||||||
|
@ -363,7 +365,9 @@ unsafe fn create_object(
|
||||||
define_prefable_methods(cx, rval.handle(), methods);
|
define_prefable_methods(cx, rval.handle(), methods);
|
||||||
define_prefable_properties(cx, rval.handle(), properties);
|
define_prefable_properties(cx, rval.handle(), properties);
|
||||||
for prefable in constants {
|
for prefable in constants {
|
||||||
define_constants(cx, rval.handle(), prefable.specs());
|
if let Some(specs) = prefable.specs() {
|
||||||
|
define_constants(cx, rval.handle(), specs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +377,9 @@ pub unsafe fn define_prefable_methods(
|
||||||
obj: HandleObject,
|
obj: HandleObject,
|
||||||
methods: &'static [Prefable<JSFunctionSpec>]) {
|
methods: &'static [Prefable<JSFunctionSpec>]) {
|
||||||
for prefable in methods {
|
for prefable in methods {
|
||||||
define_methods(cx, obj, prefable.specs()).unwrap();
|
if let Some(specs) = prefable.specs() {
|
||||||
|
define_methods(cx, obj, specs).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +389,9 @@ pub unsafe fn define_prefable_properties(
|
||||||
obj: HandleObject,
|
obj: HandleObject,
|
||||||
properties: &'static [Prefable<JSPropertySpec>]) {
|
properties: &'static [Prefable<JSPropertySpec>]) {
|
||||||
for prefable in properties {
|
for prefable in properties {
|
||||||
define_properties(cx, obj, prefable.specs()).unwrap();
|
if let Some(specs) = prefable.specs() {
|
||||||
|
define_properties(cx, obj, specs).unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -557,24 +557,17 @@ pub struct Prefable<T: 'static> {
|
||||||
pub pref: Option<&'static str>,
|
pub pref: Option<&'static str>,
|
||||||
/// The underlying slice of specifications.
|
/// The underlying slice of specifications.
|
||||||
pub specs: &'static [T],
|
pub specs: &'static [T],
|
||||||
/// Whether the specifications contain special terminating entries that should be
|
|
||||||
/// included or not.
|
|
||||||
pub terminator: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Prefable<T> {
|
impl<T> Prefable<T> {
|
||||||
/// Retrieve the slice represented by this container, unless the condition
|
/// Retrieve the slice represented by this container, unless the condition
|
||||||
/// guarding it is false.
|
/// guarding it is false.
|
||||||
pub fn specs(&self) -> &'static [T] {
|
pub fn specs(&self) -> Option<&'static [T]> {
|
||||||
if let Some(pref) = self.pref {
|
if let Some(pref) = self.pref {
|
||||||
if !prefs::get_pref(pref).as_boolean().unwrap_or(false) {
|
if !prefs::get_pref(pref).as_boolean().unwrap_or(false) {
|
||||||
return if self.terminator {
|
return None;
|
||||||
&self.specs[self.specs.len() - 1..]
|
|
||||||
} else {
|
|
||||||
&[]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.specs
|
Some(self.specs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue