Rename ComponentDefintion::callback_names() to just callbacks()

That's consistent with properties().
This commit is contained in:
Simon Hausmann 2021-06-07 12:08:35 +02:00
parent 855808f9b5
commit c0511a54ea
4 changed files with 10 additions and 12 deletions

View file

@ -712,12 +712,11 @@ public:
/// Returns a vector of strings that describe the list of public callbacks that can be invoked
/// using ComponentInstance::invoke_callback and set using ComponentInstance::set_callback.
sixtyfps::SharedVector<sixtyfps::SharedString> callback_names() const
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks() const
{
sixtyfps::SharedVector<sixtyfps::SharedString> callback_names;
cbindgen_private::sixtyfps_interpreter_component_definition_callback_names(&inner,
&callback_names);
return callback_names;
sixtyfps::SharedVector<sixtyfps::SharedString> callbacks;
cbindgen_private::sixtyfps_interpreter_component_definition_callbacks(&inner, &callbacks);
return callbacks;
}
/// Returns the name of this Component as written in the .60 file

View file

@ -313,7 +313,7 @@ SCENARIO("Component Definition Properties")
REQUIRE(properties[0].property_name == "test");
REQUIRE(properties[0].property_type == Value::Type::String);
auto callback_names = comp_def.callback_names();
auto callback_names = comp_def.callbacks();
REQUIRE(callback_names.size() == 1);
REQUIRE(callback_names[0] == "dummy");
}

View file

@ -611,7 +611,7 @@ impl ComponentDefinition {
}
/// Returns the names of all publicly declared callbacks.
pub fn callback_names<'a>(&'a self) -> impl Iterator<Item = String> + 'a {
pub fn callbacks<'a>(&'a self) -> impl Iterator<Item = String> + 'a {
// We create here a 'static guard, because unfortunately the returned type would be restricted to the guard lifetime
// which is not required, but this is safe because there is only one instance of the unerased type
let guard = unsafe { generativity::Guard::new(generativity::Id::new()) };
@ -949,7 +949,7 @@ fn component_definition_properties2() {
assert_eq!(props[0].0, "sub_text");
assert_eq!(props[0].1, ValueType::String);
let callbacks = comp_def.callback_names().collect::<Vec<_>>();
let callbacks = comp_def.callbacks().collect::<Vec<_>>();
assert_eq!(callbacks.len(), 1);
assert_eq!(callbacks[0], "hello");
}

View file

@ -736,12 +736,11 @@ pub unsafe extern "C" fn sixtyfps_interpreter_component_definition_properties(
/// Returns the list of callback names of the component the component definition describes
#[no_mangle]
pub unsafe extern "C" fn sixtyfps_interpreter_component_definition_callback_names(
pub unsafe extern "C" fn sixtyfps_interpreter_component_definition_callbacks(
def: &ComponentDefinitionOpaque,
callback_names: &mut SharedVector<SharedString>,
callbacks: &mut SharedVector<SharedString>,
) {
callback_names
.extend((&*def).as_component_definition().callback_names().map(|name| name.into()))
callbacks.extend((&*def).as_component_definition().callbacks().map(|name| name.into()))
}
/// Return the name of the component definition